Reputation: 27295
On more than one occasion, I have accidentally changed the deployment target of my Xcode project to something I don't want. The latest time, I found out because a customer wasn't seeing my app. Is there a way to put something into my code somewhere to assert the value of the deployment target? I think I would be much less likely to change that by mistake.
Upvotes: 2
Views: 4128
Reputation: 12714
Add a New Run Script Build Phase to your target and put this script inside:
DEPLOYMENT_TARGET_VALID=`expr ${IPHONEOS_DEPLOYMENT_TARGET} \>= "4.0"`;
if [ $DEPLOYMENT_TARGET_VALID = 1 ]; then
echo "Deployment target ($IPHONEOS_DEPLOYMENT_TARGET) is too high."
exit 1
fi;
Here, build will fail if the deployment target is set to 4.0 or higher.
Upvotes: 1
Reputation: 170839
You can check your deployment target version via __IPHONE_OS_VERSION_MIN_REQUIRED
macro and compare it to some sdk version, e.g. to make sure that your deployment target is 4.0 put the following lines somewhere:
#if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_4_0
#error wrong deployment target - should be 4.0
#endif
Upvotes: 6