在 xcode 5 编译中忽略 ios8 代码 [英] ignore ios8 code in xcode 5 compilation

查看:30
本文介绍了在 xcode 5 编译中忽略 ios8 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个团队正在处理一些 IOS 代码.一位开发人员(我)拥有带有几行 IOS8 特定代码的 Xcode6-beta.当另一个使用 Xcode5 的开发人员为 IOS7 构建它时,编译失败,因为他不存在 IOS8 SDK.

I've got a team working on some IOS code. One developer (me) has Xcode6-beta with a few lines of IOS8 specific code. When another developer with Xcode5 builds it for IOS7, compilation fails, because the IOS8 SDK doesn't exist for him.

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
    // ios8 code
} else {
    // ios7 and less way
}

有没有办法在基于SDK或Xcode版本的Xcode编译中忽略IOS8代码,使其编译?

Is there a way to ignore the IOS8 code in Xcode compilation based on the SDK or Xcode version, such that it compiles?

推荐答案

是的,您可以使用指令来做到这一点:

Yes, you can do this using directives:

#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
// target is iOS
    #if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
    // target is lower than iOS 8.0
    #else
    // target is at least iOS 8.0
    #endif
#endif

这类似于注释掉不需要的代码行,但会自动注释掉.编译器不包括存储在 if 语句的 8.0 特定部分的所有内容.

This is similar to commenting out unneeded lines of code but automatically. Compiller does not include everything which is stored 8.0-specific part of the if-statement.

这篇关于在 xcode 5 编译中忽略 ios8 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆