Xcode -- get force_load to work with relative paths

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.


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.