0

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!

Manni
  • 11,108
  • 15
  • 49
  • 67
  • possible duplicate of [How to "add existing frameworks" in Xcode 4?](http://stackoverflow.com/questions/3352664/how-to-add-existing-frameworks-in-xcode-4) – jww Jul 03 '14 at 05:36

2 Answers2

1

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.

Mathieu Hausherr
  • 3,485
  • 23
  • 30
  • Creating a universal static library with lipo has worked and I copy my target to get another one, but how do I add the .a in the target? – Manni Nov 10 '11 at 08:00
  • Select tour target > build phase > link binary with library > (+) and choose your .a file. The .a file must be added in the Xcode project – Mathieu Hausherr Nov 10 '11 at 11:11
  • You really have to create two different targets, one for debug and one for release? That kinda sucks. – Cthutu Apr 24 '12 at 21:05
  • You only have to do that if you have to use library build for Debug & Release. Why don't you just use Release for device and Debug for simulator? – Mathieu Hausherr Apr 25 '12 at 09:34
0

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
UPT
  • 1,490
  • 9
  • 25