Accessing Deployment Target in unit test code

孤人 提交于 2019-12-02 07:11:19

问题


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)?


回答1:


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



回答2:


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.)



来源:https://stackoverflow.com/questions/17979694/accessing-deployment-target-in-unit-test-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!