xcode project-/target-settings-syntax for linker flag force_load on iPhone
I just tried this. I've compiled a static armv6, armv7, and i386 fat binary of PCRE for use in my iPhone project. My project normally just has my library added to the project and that links fine. So I unchecked the target membership box for libpcre.a and rebuilt. As expected, I get a bunch of missing symbol linker errors for the pcre symbols. Then I opened the target settings window and edited the "Other Linker Flags" section. I added:
-force_load lib/pcre/libpcre.a
The lib
directory is in the same directory as my project.xcodeproj file.
It linked fine so I know the force_load command worked (and I can see it added to the build flags when xcode builds the file).
Hope that helps.
Update:
I also tried adding a system library to the "Other Linker Flags" line like so:
-force_load src/pcre/libpcre.a -force_load ${SDKROOT}/usr/lib/libz.dylib
That worked too.
I just added force_load to our project and all is fine using the simplest syntax possible. The library is a dependency built in the same project. The library is therefore included on the link command-line twice: once as a normal input file and once as an argument to -force_load. You might want to put quote characters around the argument.
In fact, I've even got this working using configuration-dependent settings (because the path is obviously different for debug vs. release and device vs. simulator).
Good luck.