我希望我的应用支持iOS 5.0。但Admob的先决条件是部署目标至少为6.0。
有没有办法编译我的应用,以便Admob仅用于运行iOS> = 6.0的设备?
我问,因为人们已经使用Apple Watch做了类似的事情,因此他们可以支持较低的部署目标:iOS7 and Apple Watch
答案 0 :(得分:2)
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
然后像这样使用
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
//do admob stuff
}
else {
//don't do admob stuff
}
还链接ios中不可用的可选框架< 6.0
P.S。宏取自this answer