iphonestatic-librariesjson-framework

json-framework error in iPhone static library


I have an iPhone app that uses the json-framework. I moved some of the code, including the json-framework source, from the main project to a static library. When I did this, the json-framework stopped getting compiled into the binary (double checked with class dump). This causes a nasty error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString JSONValue]: unrecognized selector sent to instance 0x43897f0'

Everything else in the static library continues to function properly.


Solution

  • Apparently, categories and static libraries don't work unless you sprinkle the magic dust on the linker flag. According to a Technical Q&A, you have to add the -ObjC linker flag to the main project (not the library, as stated in the Q&A).