views:

343

answers:

1

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.

+1  A: 

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.

Ramin
Thanks! Anyway to accomplish this without another target and just using the XCode Profiles build settings?
CVertex
The trouble is if both blah-device.a and blah-simulator.a export the same symbols. One way around this is to test based on #if TARGET_IPHONE_SIMULATOR ... in the header and define Foo as a preprocessor macro for FooDevice vs. FooSimulator. Then you can include both libraries and the right symbol is linked. But if both libraries include the same linker symbols then you'll get duplicate symbol errors. In that case, the only way is to exclude one from linking under one situation vs. the other. You can fiddle with linker path values but it's much easier to go with multiple targets.
Ramin