Manni
Manni

Reputation: 11148

Add a ".a"-library to Xcode 4

I already read a lot of hints how to add an existing framework to Xcode 4, e.g.: http://www.thinketg.com/Company/Blogs/11-03-20/Xcode_4_Tips_Adding_frameworks_to_your_project.aspx

But my question is very special.

I want to add a library that has the following structure:

If I want to build my project to test it on a simulator, I have to copy the library from the folder "Debug-iphonesimulator" to my project. If I want test it on the device, I have to copy the library from the folder "Release-iphoneos". That's very cumbersome!

Is the a good way to integrate all librarys in my project?

Thank you very much!

Upvotes: 0

Views: 2064

Answers (2)

UPT
UPT

Reputation: 1480

There is another simple way. Provide the path of .a file in other linker flag with the corresponding target.

Suppose you are building your application for device it should link to device version of .a and when you are building your application for simulator it should link to simulator version on .a

Here is how you should provide the other liker flag:

../../../testApp/DerivedData/testApp/build/Products/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/testApp.a

Upvotes: 0

Mathieu Hausherr
Mathieu Hausherr

Reputation: 3485

A first step is to create universal static library with the lipo command

lipo -create "${PROJECT_DIR}/build/${BUILD_STYLE}-iphoneos/libYourLib.a" "${PROJECT_DIR}/build/${BUILD_STYLE}-iphonesimulator/libYourLib.a" -output "${PROJECT_DIR}/build/libYourLib-${BUILD_STYLE}.a"

After that create 2 different target (for debug and release) and add the correct .a in each.

Upvotes: 1

Related Questions