How to link different precompiled libraries for different build profiles in XCode for iPhone?

StackOverflow https://stackoverflow.com/questions/1736800

  •  20-09-2019
  •  | 
  •  

Question

My client is providing me with two precompiled libraries, blah-device.a and blah-simulator.a. How do I tell xcode to use blah-device.a in Device compilation mode and simulator in Simulator compilation mode?

My client gives me these instructions

  1. Open the Targets group (in the Groups & Files panel), right-click the project icon, then select Add > Existing Frameworks.
  2. In the Linked Libraries section, click the Add Libraries icon (+) icon, then click Add Other.
  3. Select either blah-device.a (for developing directly on the iPhone device) or blah-simulator.a (for developing on the iPhone Simulator), then click Add.

I already copied the header file in there, however these instructions don't make building easy with different profiles.

How do I get Xcode to link blah-device.a when building with the DEVICE profiles and blah-simulator.a when building with the SIMULATOR profiles?

Any help is greatly appreciated.

Was it helpful?

Solution

There is an easier way to do that. You can duplicate the "Library Search Paths" under one target and set a different architecture for each one. You can then set a different path for simulator and devices.

OTHER TIPS

For future reference, a good way to handle situations like this is to glob the different architecture .a's into a single one that you can include in XCode. You can do this with the lipo command line tool:

lipo libx.a liby.a -create -output libz.a

If libx.a is armv6 and armv7 and liby.a is i386 for example, the resulting library, libz.a, will be armv6, armv7, and i386.

You can also inspect a .a file via lipo -info.

Hope this helps. :)

you can use different linking path's for different libraries linking path's

The easiest way would be to create two separate targets by duplicating your existing one. Name one "Foo Device" and the other "Foo Simulator." Then right-click on the blah-device.a in XCode, select the Targets tab and make sure the "Foo Device" target is checked ON and the "Foo Simulator" target is checked OFF.

Repeat for balah-simulator.a but this time "Foo Device" target is OFF and "Foo Simulator" target is checked ON.

Now whenever you want to do a simulator build make sure you select the Simulator from the Active SDK popup AND the "Foo Simulator" from the target popup. For device testing select Device AND the "Foo Device" target.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top