Search code examples
iphoneiosxcode4

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:

  • build -> Debug-iphoneos -> library.a
  • build -> Debug-iphonesimulator -> library.a
  • build -> Release-iphoneos -> library.a
  • build -> Release-iphonesimulator -> library.a

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!


Solution

  • 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.