Three20 for iPhone: Add JSON support to a new project


Working on a new iPhone app, everything was going smoothly with Three20, following their guide to add Three20 to your application with a Python script. Everything was working smoothly until I wanted to parse some JSON. The ttmodule.py script added the frameworks for the other Three20 modules (considered core) to my XCode project, but didn’t include the JSON+SBJSON module (considered external or optional) in the linker flags. This was a little confusing, as the JSON library was listed as a direct dependency.

EveryMarathon Dependencies for Three20

I had to add the following lines to my linker flags (from the info window for your target, go to “Build”, then look under the “Linking” header, and then “Other Linker Flags”. You’ll see some Three20 linker flags there, for the SBJSON library, add two lines:

-force_load
../../three20/Build/Products/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/libextThree20JSON+SBJSON.a

Where ../../three20 matches the location of your other Three20 libraries (this will depend on where you put the Three20 source code).

How it looks in XCode:

EveryMarathon Linker Flags

I hope this helps other iPhone developers who are using Three20! Mostly I put these tips together for my future reference.