Reputation: 3847
I am sure this has been asked before, however I have been banging my head against a brick wall all afternoon trying to figure out how to achieve this using XCode 4.
I have a lib which was distributed by a 3rd party. They actually ship 2 different versions, one for use in the simulator, and one for use with the actual device.
I would like to know, what is the recommended way for handling situations like this in XCode 4; in XCode 3, I could simply have specified a new target. I wish to avoid creating a fat binary via lipo containing both libs, but if that is the only feasible option available to me, then so be it.
Ideally what I would like to do is modify the Library Search path based upon the current device the project is being compiled for such as:
Simulator: /path/to/simulator/lib.a
Device /path/to/device/lib.a
If I could automate the process so once I had set it up, it was transparent, all the better.
Many thanks for taking the time to read this.
Upvotes: 5
Views: 6726
Reputation: 926
XCode define $(EFFECTIVE_PLATFORM_NAME)
to be 'iphoneos' or 'iphonesimulator' base on the target "device". As long as your library path includes one of those strings, you can set
LIBRARY_SEARCH_PATHS
in your targets or project to something like:
/path/to/$(EFFECTIVE_PLATFORM_NAME)/lib.a
Hint: you can see this in action by clicking "All" in Building Settings, and then selecting Editor > Show Setting Names and Editor > Show Setting Definitions in the menus. To see if the final value is what you expect, switch back to values using Editor > Show Setting Values.
Upvotes: 8
Reputation: 75058
You can still create new targets in XCode4 - just go to your project in the navigator sidebar, select it and in the project editor you can select "new target".
However I would actually recommend you use lipo to create a fat binary. I believe the simulator part gets stripped out as part of the build phase so it should not impact executable size.
Upvotes: 3