Can I indicate that a device or simulator is always used to create a specific goal?

I have a static library with two different goals: one for assembly for the device, one for assembly for the simulator. Finally, I have a goal that combines two goals using lipo.

Currently, I have to create each goal manually and indicate that the goal of the simulator should be built for the Simulator, and the goal of the device should be built for the device.

If I use one of these goals as a build dependency, they will either be built for the device or for the simulator. Is there a way that I can make every goal always build for a device / simulator accordingly?

+3
source share
2 answers

This can be easily done using the xcodebuild command line:

$xcodebuild -target <target name> -configuration <configuration name> -sdk iphonesimulator build
$xcodebuild -target <target name> -configuration <configuration name> -sdk iphoneos build

Then, for your lipo goal, you can add a script build phase in which you can run two commands before combining them with lipo.

If your first two goals are separated just to create the right SDK, now you can remove one of them and run the same build command twice, installing only the other SDK. You should also consider running lipo in the Makefile, in which case you will not need a lipo target either.

considers

+2
source

You can restrict the assembly by placing certain conditions in the code. But they will work after installing the application on the device.

"application doneFinishLaunch" , .

#if TARGET_IPHONE_SIMULATOR
if([[[UIDevice currentDevice] systemVersion] floatValue] == requierdSimulatorVersion){

}
else{
     exit(1);
}
#else
if([[[UIDevice currentDevice] systemVersion] floatValue] == requierdDeviceVersion){

}
else{
     exit(1);
}

#endif

,

-1

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


All Articles