Getting a static library to work on the iPhone in SDK 3
We are currently working on a lightweight game library for the iPhone. The library is static and is thus linked to the game at compile-time. In the iPhone simulator, it was working perfectly fine.
Then I wanted to do start the demo application on the actual device. For whatever reason, the classes of the library were not recognized on the device at runtime – even though the build log did not note any problems, and the library should have been linked to game. I could not think of anything that would lead to this behavior!
Fortunately, big brother Google was there for the rescue. There seems to be bug in the linker of iPhone SDK 3.0. The fix is easy (if you know it):
In addition to the linker flag ”-ObjC” you have to add the flag ”-all_load”. After that, everything works just like it should.
I suspect that Apple fixes this in the next SDK version, but until then, I can live with that.