Xcode — get force_load to work with relative paths

后端 未结 2 536
不思量自难忘°
不思量自难忘° 2020-12-01 09:29

Some libraries require the -all_load linker flag when linking to an Xcode project. However, this leads to a linker error if there are symbol conflicts among libraries. The

相关标签:
2条回答
  • 2020-12-01 10:13

    With Xcode 4, if you include the library project into your app project, then you can add this to the Other Linker Flags:

    -force_load $(BUILT_PRODUCTS_DIR)/<library_name.a>
    

    You still need the dependency, and you need to add the library in the Link Phase list of frameworks and libraries too.

    EDIT: Apple now says as of some Xcode 4 release that you can simply use this linker flag: "-ObjC" to get libraries with categories to properly load. That flag is working just fine for me in Xcode 5. People are still up voting this answer, but I suspect that the -ObjC flag is the best solution now.

    0 讨论(0)
  • 2020-12-01 10:19

    This worked for me. Like the above answers you still need to include the library in the project.

    -force_load $(SRCROOT)/pathToLibraryFromProject/libname.a
    

    For the path it's just the folders in your project that lead to where you put your library, for example BaseFoler/Subfolder/libName.a.

    0 讨论(0)
提交回复
热议问题