Agregue una biblioteca ".a" a 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?

Muchas gracias!

preguntado el 08 de noviembre de 11 a las 09:11

2 Respuestas

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.

respondido 08 nov., 11:13

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

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

You really have to create two different targets, one for debug and one for release? That kinda sucks. - Cthutu

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

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

respondido 08 nov., 11:13

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.