2

I've got one Xcode project (let's call it "first") using another ("second"). The second project is built into static library, and the first project is using this library. I'd want to use linker flag -force_load to that library in first project. The problem is that library is built when I start to compile these projects, so in Xcode library is marked red, and that means I don't know the path where it is. How could I see it? In "build settings" of second project I can see "installation directory" with "usr/local/lib", but when I type "-force_load usr/local/lib/mylib.a" it says that linker could not find file.

When I build only the lib, I can add it to the project, set -force_load and everything seems to be ok, but that is not what I want. I don't want to use -all_load, even if it loads all libraries and I may not to know paths t them.

Thanks!

medvedNick
  • 4,512
  • 4
  • 32
  • 50
  • Can I ask what is the reason you want to add **-force_load** flag? Are your categories defined in the library not visible in the "first" project when the library is set up as direct dependency? – lawicko Feb 29 '12 at 15:00
  • yes, there are categories. They're visible, but building without that flag causes runtime errors in app. I prefer to use -load_all, but the first project has many files that are not included in finish binary, and there are "int main(..." and other duplicated symbols and etc. – medvedNick Feb 29 '12 at 15:56
  • 2
    I've found the similar [question](http://stackoverflow.com/questions/4787279/xcode-get-force-load-to-work-with-relative-paths) that describes what you need to do. I tried this solution myself, and it works fine. You need to do something similar to `-force_load $(BUILT_PRODUCTS_DIR)/libSecond.a` – lawicko Feb 29 '12 at 17:55
  • thanks, that is exactly what I was searching for! but it's strange why I didn't find it myself – medvedNick Mar 01 '12 at 10:58
  • and, by the way, don't you know how to set flag "-all_load" only for second project? it does not using flags in implicit projects, as I see – medvedNick Mar 01 '12 at 11:11
  • The nature of **-all_load** is that it, well, loads all :-) It's an equivalent of addint **-force_load** for every archive you want to link. See [here](https://developer.apple.com/library/mac/#qa/qa1490/_index.html). – lawicko Mar 01 '12 at 11:33

0 Answers0