Install json-framework

If you are attempting to write a Iphone application to talk to a webservice, JSON is one of the best ways to go. Now unfortunately there is no native support in the Iphone SDK for JSON. There is a project called json-framework that provides a framework called json-framework.

There is little documentation on how to install it though. Recently I found a news group posting on how to do it along with a dmg! I have mirrored the dmg file just in case it gets removed from that posting.

So here are some instructions on how to install it.

  • Download the dmg file
  • Make a directory called SDKs in your ~/Library/ directory. So if you username is bob. it would be /Users/bob/Library/SDKs
  • Copy the JSON directory to SDKs so you should have a directory called /Users/bob/Library/SDKs/JSON which has iphoneos.sdk and iphonesimulator.sdk directories inside it.
  • In Xcode load up your project and go to Project -> Edit Project Settings. You will see a box like this

  • At the top you will see Additional SDKs. Double click that and you will see

  • Now click the + sign and it will prompt you to add a directory. You will enter the following line
$HOME/Library/SDKs/JSON/$(PLATFORM_NAME).sdk
  • Now you need to add in the linker options. So now look for Other Linker Flags and add in the following
-ObjC -ljson
  • Now you can import the <JSON/JSON.h> header file and begin coding.

I have also mirrored their test application they built in the news group post. So if you download that and make the project changes there, you should be able to compile touchJSON into your application.

About mike
Currently works for OpenSky as a Senior Linux Admin. He has a wonderful wife Thanuja and 2 great dogs. His major side project is Photoblog.

Comments

29 Responses to “Install json-framework”
  1. Hi, I’m the author of both the JSON Framework and the newsgroup posting you reference above.

    I just wanted to let you know that from version 2.1 onwards, official downloads of the framework come with iPhone-ready SDKs.

    (BTW: I’m a bit curious why the the slug refers to touchjson; that’s part of an unrelated project called touchcode.)

  2. David Widman says:

    Hello,

    I can’t make the JSON sdk run with SDK 2.1. I keep getting the following error: JSON/JSON.h: No such file or directory. When I open your project, it works. I checked extensively the “Additional SDKs” and the “Other Linker Flags” and they are exactly the same as your project. Please HELP HELP HELP.

    David

  3. Levous says:

    I just started using google toolkit for mac, including unit testing framework. When I build using the unit test target (set up according to their tut), the Json framework is not linking and the selectors are unrecognized.

    Any idea what I need to do so that json framework loads into testing context?

  4. Levous says:

    Got this resolved! I had failed to add “Other Linker Flags” to the “Unit Test” target. You have to set up the Unit Test target separately from your main app target and associate the same links. Works like a CHARM!

  5. Andy Atkinson says:

    Hello, I have added the JSON.framework to ~/Library/Frameworks, added the parts to “Additional SDKs” and “Other Linked Flags” mentioned here, and still can’t compile code that includes the JSON framework. I completed the instructions here in comments as well, trying to create another target, as well as the instructions in the INSTALL of the DMG download. I am on Xcode 2.2.2 and running latest Leopard. Any more help please?

  6. Andy Atkinson says:

    Whoops make that Xcode 3.1.1

  7. Felix says:

    I also had problems getting this to work in XCode 3.1.1, until I changed

    $HOME/Library/SDKs/JSON/$(PLATFORM_NAME).sdk

    to

    $HOME/Library/SDKs/JSON/$(PLATFORM_NAME).sdk/

    Also, I copied the JSON folder into place from the command line, since Finder was tricking me with the file locations somehow.

    Hope it helps.

  8. Felix says:

    Hmm… However, I did *not* have to make that change in order to compile the testjson project in the next post. Does anyone have a clue why this should be?

  9. rivertiger says:

    Test example worked like a charm! Excellent package…going to try it using the Google AJAX Search API (non-js)…and see what data it returns.

  10. totiz says:

    Thanks every much.
    You’ve helped me alot.

  11. Thomas Swedin says:

    Just add -ObjC in Other Linker Flags in project settings, else you will have compile error.

  12. Craig Walton says:

    Brilliant – thanks so so much!

  13. Harshit says:

    i followed all the steps explained above and then developed a demo project based upon it…and there is only one error..that i couldnt resolve….

    the error is:

    ld: library not found for -lgcc_s.10.5
    collect2: ld returned 1 exit status
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

    please help me..thnx in advance

Trackbacks

Check out what others are saying about this post...
  1. [...] Seems someone on a new group put together a dmg for touchjson yesterday. Here is a link to my blog on how to install it if anyone else is wondering this Install TouchJSON | Iphone Noob [...]

  2. [...] now that we have the basics of installing JSON to our project, lets make a test [...]

  3. [...] sure you have JSON Framework installed [...]

  4. [...] sure you have JSON Framework installed [...]

  5. [...] sure you have JSON Framework installed [...]

  6. [...] sure you have JSON Framework installed [...]

  7. [...] sure you have JSON Framework installed [...]

  8. [...] sure you have JSON Framework installed [...]

  9. [...] sure you have JSON Framework installed [...]

  10. [...] experience with the iPhone Xml parser.  Its germane and, frankly, annoying.  Here’s how to install JSON for the iPhone. and here’s how to use JSON for the iPhone.Got it, Keep itNow that we’ve retrieved our [...]

  11. [...] opción nos la proporciona la inclusión de un interesante FrameWork en nuestro proyecto, mediante el cual podemos volcar todo el contenido de dicho fichero o [...]

  12. [...] found this JSON framework written in Objective-C. I wasn’t able to get as I had some weird build errors after following the installation [...]

  13. [...] sure you have JSON Framework installed [...]

  14. [...] sure you have JSON Framework installed [...]

  15. [...] sure you have JSON Framework installed [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!