Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode project-/target-settings-syntax for linker flag force_load on iPhone

Tags:

I am confronted with the double bind. On the one hand, for one of the 3rd party static libraries my iPhone application uses, the linker flag -all_load has to be set in the application project or target settings. Otherwise, the app crashes at run-time not finding some symbols called internally from the lib. On the other hand, for another 3rd party static lib, -all_load must not be set on application level, or the app won't build thanks to a "duplicate symbols" linker error.

To solve this issue, I now want to use force_load instead of load_all, as it due to documentation it does the same like all_load, but only for the passed path or lib-file, instead of all libs.

The problem with force_load is, I do not have a clue how to pass a path or file as parameter with it, when passing it via XCode project- or target-settings. All syntax-possibilities I tried either lead xcode to thinking it's another linker flag instead of a parameter to the previous one, or the linker throwing syntax related errors, or the flag simply does nothing at all.

I also opened the .pbxproj-file in a text-editor to edit it to the correct command line syntax manually. But when reloading the project with XCode, it auto-changes the syntax into interpreting the parameter to force_load as a separate flag.

Anyone have an idea on this issue?

like image 492
Kaiserludi Avatar asked Jul 28 '10 16:07

Kaiserludi


Video Answer


1 Answers

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.

like image 88
par Avatar answered Sep 23 '22 06:09

par