how to add JSON framework - iphone

Goal : Add the latest JSON into my project.
I download JSON from this link https://github.com/stig/json-framework/downloads and drag the folder name stig-json-framework-a23638b in my project. and Check “Copy items into destination group’s folder (if needed)”.
stig-json-framework-a23638b folder shows many sub folder inside like Classes, Examples, SBJSON, sbjson-ios, sbjson-iosTests.
after that when I #import "JSON.h" it gives error JSON.h file not found.
I know I am doing wrong please direct me in right direction. and provide me link from where I download JSON Framework. and any good tutorial links.
many thanks.

You dont need to import the whole project with examples and target of it.Just import whatever in the "classes" folder in that framework..
https://github.com/stig/json-framework/tree/master/src/main/objc
Files listed in above link is enough to import framework.
As #sanchitsingh said, you need to import only "SBJSON.h".

There is no file JSON.h.
Try this
#import "SBJson.h"

Related

Sqlite for custom swift framework

I am creating a custom swift framework for managing all common data of my applications like data base or common classes.
I import the library "libsqlite3.0.tbd" in Linked Frameworks and Libraries, but when I try to put #import "sqlite3.h" in my Umbrella header file, I recite the next error:
Include of non-modular header inside framework module
Any idea?
Thank you very much
Step by Step what I did with my sqlite project for it to work, try this (keep the library added and the #import statement in the header):
First, remove the Header from Build Phases >> Headers.
Then go to Build Settings and add the path to the Header in the Objective-C Bridging Header. If you just created the Framework, didn't change the name of the .h file and your project is called Test, for example, the path will be Teste/Test.h (Xcode 7.1.1).
Hope it works.

Static Library path nightmare from hell

This is the point. I have a subproject (static library) created. The library compiles well. No errors. When I include this library inside a project and imports a header from that library on the project the library fails to compile because it cannot find a path that belongs to itself.
After following a bunch of tutorials on the web on how to create a static library and embed that in a project, I don't know which one is the correct one, because I have tried all and all failed and some differ.
This is how the library is set:
STATIC LIBRARY
BUILD SETTINGS:
Public header folder path = $(BUILT_PRODUCTS_DIR)
Header search path = $(SRCROOT) (recursive)
BUILD PHASES
COPY FILES = 1 file, myLibrary.h that is basically empty (created by xcode when I used the static library template to start the library.
no ADD COPY HEADERS phase
MAIN PROJECT
BUILD SETTINGS
Header search path = empty
User header search path = $(BUILT_PRODUCTS_DIR) (recursive)
Always search user paths = YES
BUILD PHASES
Yes, myLibrary.a is on target dependencies
What amazes me is that the library compiles fine alone but when put inside a project, is unable to find a header that belongs to the own library.
NOTE: I have also tried to create a copy headers phase on the library making public all .h on that library, but it failed too.
This is an example of one error:
/Users/mike/Library/Developer/Xcode/DerivedData/MyApp-dnaimaovscreasadhmvgttwjnabc/Build/Products/Debug-iphoneos/include/myLibrary/ccTypes.h:39:9:
fatal error: 'Platforms/CCGL.h' file not found
#import "Platforms/CCGL.h"
I have lost two days trying to solve this nightmare.
any thoughts?
I have uploaded a sample project to here and here
After downloading your sample project, I had it working in a few minutes by making the following changes.
First, you need to add an entry for the MyProject target's Build Settings under Header Search Paths, so that the files such as HelloWorldLayer.h, which #import "cocos2d.h", know where to find that file.
Under the Header Search Paths, I entered ../MyStaticLibrary/MyStaticLibrary/libs/** like shown in the image below:
That solved the problem of the inability of the preprocessor to find the necessary source files from the MyStaticLibrary, for the MyProject project, but after compiling, I got an error about missing symbols. I needed to add the built libMyStaticLibrary.a to the Link Binary With Libraries step like shown in the image below:
After that, the project compiles fine.
(Not enough rep to post comment...)
Did you try specifically including the Platforms directory in the header search path? Presumably, Platforms is in the source directory, not in $(BUILT_PRODUCTS_DIR) so may not be searched in your current setting.
Regarding script to show you env variables, here's how I do it (open images at the new tab for better scaling):
Added dummy shell script
Observed its output at Log Navigator
As you can see, BUILT_PRODUCTS_DIR doesn't have any headers copied from the library. Either put headers there manually (strongly not recommended) or add search path to the location that you know the headers must be at:
Now as there were two headers cocos2d.h and MyStaticLibrary.h, cocos2d.h was successfully imported although it will have additional dependency.
The path ../MyStaticLibrary/build/$(BUILD_STYLE)-$(PLATFORM_NAME) will also (recursively) have public headers of the library.
After almost 5 days of a nightmare trying to solve that, I finally found this tutorial: http://www.youtube.com/watch?v=XUhLETxgcoE
This is the only solution that worked for me. The simplest and the best.
Thanks for every one trying to solve this.
Please try this…
step1: right click on the 'projectName.xcodeproj'(static library).Choose 'Get info' and copy the full path from(General->where)
step2: Paste full path to 'Header search paths' for your main project(Both Targets and Project )

problem sending mail from backend file not found iphone

i'm trying to use the skpsmtpmessage to send emails from backend. In the README.txt it says:
To use this in your app include the following files in your project:
SKPSMTPMessage.*
NSStream+SKPSMTPExtensions.*
That should mean that i have to include the .h .m files in my project. Now, after i've done that i get an error NSData+Base64Additions.h not found, so i imported the missing classes for this 'skpsmtpmessage' project but i get tons of errors like:
Undefined symbols for architecture armv6:
"_kCFStreamSSLLevel", referenced from:
-[SKPSMTPMessage parseBuffer] in SKPSMTPMessage.o
i get the same errors if i even remove the import lines. I cleaned the project but it doesn't help at all.
Has anyone used this library before? Have you experienced this errors before? I need some guide.
Thanks in advance!
Have a look at the header files for the project you've downloaded. You'll see this:
#import <CFNetwork/CFNetwork.h>
This means that the class uses the CFNetwork framework. You will need to add it to your project in Xcode and make sure that your target links against the framework.

iPhone : Problem while fetching the twits from twitter

In my iphone app, I am trying to fetch twits from twitter.
And I got one example coding from following link :
http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/
But when i implemented this example I got following warning:
Directory not found for option '-L/Volumes/MacShare/Ankit/Twitter Search/JSON/iphoneos.sdk/usr/local/lib'
What can be done?
I think you are forgetting the step of copying the JSON framework in your project -
# Drag the JSON folder from the DMG and drop it in your Xcode project. You can add it to the “Other Sources” group if you would like.
# Select the ‘Copy items into destination group’s folder’ option when prompted.
I just downloaded the code from http://mobiletuts.s3.amazonaws.com/14_iPhoneJSONFramework/JSONTwitterSearch.zip and its working great!!
follow the steps carefully!!
You can do one more thing.. download their source code and drag the Json folder from their project to your project..

`#import "FBConnect.h"` vs. '#import "FBConnect/FBConnect.h" '

It took me some time to get XCode to locate the Facebook sdk.
I added ‘....../facebook-ios-sdk/src ‘ into ‘Header Search Paths’ in ‘Project Settings’ (the ‘Header Search Paths’ in the ‘Target Info’ does not show the directory however) , and use:
#import "FBConnect.h" ,
instead of #import "FBConnect/FBConnect.h", then the XCode can locate the facebook sdk.
As the 'FBConnect.h' is directly under the /src, where is the 'FBConnect'? What does "FBConnect/FBConnect.h" mean? Do you guys use #import "FBConnect/FBConnect.h" without manually adding a 'FBConnect' directory or Group in XCode?
I also use #import "FBConnect/FBConnect.h" in my projects, but you don't need to add the Facebook iOS SDK to your search paths in Xcode. Xcode automatically adds paths for compilable files in your source tree to gcc's list of include paths. Groups in Xcode are only for your peace of mind and project organization -- they have absolutely no effect on your project's build settings. The use of FBConnect here refers to a subdirectory on the filesystem, not the actual group name in your project.
Keep in mind that there are actually two Facebook SDKs available for the iPhone: facebook-ios-sdk and facebook-iphone-sdk. I'm not 100% sure as to why, but I think that the facebook-iphone-sdk is being deprecated in favor of the new one. Since Facebook (for some odd reason) chose to put their header files in an additional subdirectory also named "FBConnect" underneath the main source directory in the facebook-iphone-sdk project, you need to add the additional FBConnect when importing this file. Also, you'll see a lot of examples referencing the old project code which uses this importing style as well.