Accessing Deployment Target in unit test code

2019-02-28 17:48发布

I need to know my deployment target in my unit test cases. Is there any way to get the iOS deployment target programmatically (using Objective-C)?

enter image description here

2条回答
闹够了就滚
2楼-- · 2019-02-28 18:10

This is available as an Xcode build variable called IPHONEOS_DEPLOYMENT_TARGET.

All you need to do is create a preprocessor macro holding that value:

and then you can refer to AMIT_DEPLOYMENT_TARGET in your code. (Note: this is a float, rather than the string you might expect.)

查看更多
劫难
3楼-- · 2019-02-28 18:26

Displays as a 'big' int:

NSLog(@"Deployment target: %i", __IPHONE_OS_VERSION_MIN_REQUIRED);

e.g. for iOS 5.1 as the deployment target

Deployment target: 50100
查看更多
登录 后发表回答