Xcode - Change library search path Based on the device whose code is compiled for

I am sure that this was asked earlier, but I always hit my head against a brick wall, trying to figure out how to achieve this using Xcode 4.

I have a lib that was distributed by a third party. In fact, they send 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 to handle such situations in Xcode 4; in Xcode 3, I could just specify a new target. I want to avoid creating a live binary file using lipo containing both libraries, but if this is the only possible option available to me, then so be it.

Ideally, what I would like to do is change the library search path based on the current device compiled by the project, for example:

Simulator: /path/to/simulator/lib.a

Device / path / to / device / lib.a

If I could automate the process, therefore, as soon as I installed it, it was transparent, the better.

Thanks so much for taking the time to read this.

+4
source share
2 answers

You can still create new goals in Xcode4 - just go to your project in the sidebar of the navigator, select it and in the project editor you can select the “new target”.

However, I would recommend you use lipo to create a thick binary. I believe that part of the simulator will be removed as part of the build phase, so it should not affect the executable size.

+2
source

Xcode defines $(EFFECTIVE_PLATFORM_NAME) as the iphoneos or iphonesimulator base on the target "device". As long as your library path includes one of these lines, you can set LIBRARY_SEARCH_PATHS for your purpose or project, for example:

 /path/to/$(EFFECTIVE_PLATFORM_NAME)/lib.a 

Hint: You can see this in action by clicking “All” in “Building Preferences” and then choosing “Editor”> “Show Names and Editor”> “Show Settings” in the menu. To find out if the final value is expected, return to the values ​​using "Editor"> "Show Setting Values".

+7
source

Source: https://habr.com/ru/post/1345947/


All Articles