Can I mandate that the device or simulator is always used to build a specific target?
I have a static library with two different targets: one to build for the device, one to build for the simulator. Finally, I have a target that combines the two targets using lipo.
Currently, I have to bui开发者_开发问答ld each target manually and specify that the the simulator target should be built for the Simulator, and the device target should be built for the Device.
If I use one of these targets as a build dependency, they will either both be built for the device or for the simulator. Is there a way that I can force each target to always build for the device/simulator respectively?
This can be easily done by using the command line xcodebuild utility:
$xcodebuild -target <target name> -configuration <configuration name> -sdk iphonesimulator build
$xcodebuild -target <target name> -configuration <configuration name> -sdk iphoneos build
Then for your lipo target you can add a script build phase in which you can run the two commands before combining them with lipo.
If your first two targets are separated just for the sake of building with correct SDK now you can remove one of them and run the same build command twice by setting only a different SDK. You should also consider running lipo within a Makefile in which case you would not need the lipo target as well.
regards
You can restrict the build by putting certain conditions in the code. But they will work once you install the App in the device.
You can put some conditions like the following in the "application didFinishLaunch" method.
#if TARGET_IPHONE_SIMULATOR
if([[[UIDevice currentDevice] systemVersion] floatValue] == requierdSimulatorVersion){
}
else{
exit(1);
}
#else
if([[[UIDevice currentDevice] systemVersion] floatValue] == requierdDeviceVersion){
}
else{
exit(1);
}
#endif
Regards,
Satya
精彩评论