Objective-C static libraries and categories
If you are building iPhone or other Mac apps with the iPhone using static libraries, reading
Technical Q&A QA1490 will help you. I was getting a problem running with FMDB because it uses categories to extend the functionality of one of its classes and failing at runtime with a selector problem.
To resolve this issue, the static library should pass the -ObjC option to the linker. This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.
In my case I had to put these flags on the primary application target (the one using the library) rather than the library itself, which strikes me as odd.
Update: You also have to add -all_load in some cases
| Permalink | Comments[6] |
Related Items
Recent Entries
» How to make the Flip Mino HD import into iMovie 09
» How to patch Xcode to work with Subversion 1.5
» iTunes 8 on Windows XP x64
» iPhone SDK Code Signing Insights
» Making iPhone Distribution Profiles Show Up
You can skip to the end and leave a response. Pinging is currently not allowed.
August 26th, 2008 at 8:37 am
Great Tip!
September 13th, 2008 at 11:01 am
You made my day!
July 27th, 2009 at 12:03 pm
I was having the same problem in SDK 3.0 and adding the flag in the target application did not help. I am going to it in the static library project later today. Hopefully this will fix the \
July 27th, 2009 at 12:07 pm
You also have to add -all_load in some cases
August 7th, 2009 at 3:56 am
Thank You!
Two days of debugging and the -all_load flag made it working …