JSON Framework InstallationHere are a few ways to start using the JSON Framework in your application. Option 1: Copy the JSON source files into your projectThis is the simplest option and should always work—regardless of whether you're creating an application for the iPhone or a desktop Mac. - Drag the JSON folder from the distribution and drop it on the 'Classes' group in the 'Groups & Files' menu of your Xcode project.
- Tick the 'Copy items into destination group's folder' option.
- Use #import "JSON.h" in your source files.
If you're upgrading from a previous version, make sure you're deleting the old JSON group first, moving all the files to Trash. Option 2: Use the iPhone Custom SDK- Create a directory ~/Library/SDKs, if it does not already exist.
- Copy the SDKs/JSON folder from this disk image into ~/Library/SDKs.
- In your Project, select your target in the left-hand menu and click the blue Info button (Apple-i) and select the "Build" tab.
- Make sure "All Configurations" is selected in the "Configuration" drop-down.
- Add the following new line to the "Additional SDKs" option: $HOME/Library/SDKs/JSON/${PLATFORM_NAME}.sdk
- Add the following two options to the "Other Linker Flags" option:
-ObjC -ljson
- Use #import <JSON/JSON.h> in your source files.
Creating custom SDKs is not very well documented from Apple, so if this option fails for you, please go with Option 1 and just copy the source into your application. Option 3: Use the Embedded FrameworkThis option will not work for iPhone applications! It only works for standard desktop Mac applications. - If it doesn't already exist, create a directory called ~/Library/Frameworks.
- Copy the JSON.framework directory to ~/Library/Frameworks.
- Use the "Add existing file" menu to add ~/Library/Frameworks/JSON.framework to your application.
- Add a "Copy files" build phase to copy the framework into your application. This should copy files to the Frameworks folder inside Resources.
- Use #import <JSON/JSON.h> in your source files.
Apple's documentation on embedding private frameworks is a good resource and explains in more detail how to do this. If you use this option you may notice a bit faster clean-and-build cycles because you don't have to rebuild the JSON sources.
|
If you get errors like »error: syntax error before 'AT_NAME' token«, »error: syntax error before '}' token« and »fatal error: method definition not in @implementation context« (described in Issue #33) with option 2 maybe it helps to change the compiler to something other than 4.2 and back again to 4.2.