Xcode 4.5 和 iOS 4.2.1 不兼容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12463195/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4.5 and iOS 4.2.1 incompatibility
提问by mskw
The latest release notes indicates 4.2.1 and lower will not be supported, we now have to use 2 version of Xcode to develop when supporting older devices?? This is going to be difficult to support older devices if we want to develop iOS6 AND support 4.2 and lower.
最新的发行说明显示不支持4.2.1及更低版本,支持旧设备时,我们现在必须使用2个版本的Xcode进行开发??如果我们要开发 iOS6 并支持 4.2 及更低版本,这将很难支持旧设备。
I don't think Xcode 4.4 will support iOS6. So this is the issue. How would developers easily support these platform without so much hassle?
我认为 Xcode 4.4 不会支持 iOS6。所以这就是问题所在。开发人员如何轻松支持这些平台?
采纳答案by Nate
You can do this, but it requires some minor Xcode hacking, and some sacrifices. Depending on what you mean by "support iOS 6", this may or may not be sufficient for you. If you just want your app to run on iOS 6, then this should work. If you also need your app to incorporate new iOS 6 features, then it won't.
你可以这样做,但它需要一些小的 Xcode hacking 和一些牺牲。根据您所说的“支持 iOS 6”的含义,这对您来说可能足够也可能不够。如果您只是希望您的应用程序在 iOS 6 上运行,那么这应该可行。如果您还需要您的应用程序包含新的 iOS 6 功能,那么它不会。
(Note for others who don't have a problem using multiple versions of Xcode: this similar questionhas answers that do allow you to also use new iOS 6 APIs and directly target armv7s)
(请注意使用多个版本的 Xcode 没有问题的其他人:这个类似问题的答案确实允许您也使用新的 iOS 6 API 并直接针对 armv7s)
See basic instructions on chpwn's blog here(but read the rest of this below, too!)
请在此处查看 chpwn 博客上的基本说明(但也请阅读下面的其余部分!)
Basically, you can use Xcode 4.5 to build for iOS 4 and above, but then you can't take advantage of the new iOS 6 only features. So, you're really building for iOS 4 and 5, and assuming that the app will run fine on iOS 6 (which should be true, but you'll need to test this yourself).
基本上,您可以使用 Xcode 4.5 为 iOS 4 及更高版本进行构建,但这样您就无法利用仅适用于 iOS 6 的新功能。因此,您实际上是为 iOS 4 和 5 构建的,并假设该应用程序可以在 iOS 6 上正常运行(这应该是正确的,但您需要自己进行测试)。
You'll need to copy the iOS 5 SDK folder
您需要复制 iOS 5 SDK 文件夹
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.*.sdk
from an old Xcode installation (which you'll need to keep around briefly, or reinstall to a non-standard location). You'll then set the Deploy Targetin your Build Settings to iOS 4.0 (or whatever minimum OS you want). You may need to open the project.pbxproj
file in a text editor to set this manually:
从旧的 Xcode 安装(您需要暂时保留,或重新安装到非标准位置)。然后,您将在 Build Settings中将Deploy Target设置为 iOS 4.0(或您想要的任何最低操作系统)。您可能需要project.pbxproj
在文本编辑器中打开文件以手动设置:
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
You'll also need to set the Architectures to armv6
and armv7
. You cannot directly alsotarget armv7s
. But, that doesn't mean your app won't run on iPhone 5. armv7
executables should run on iPhone 5, simply without any optimizations added in armv7s
. It's just that compatibility doesn't work in the other direction (e.g. armv7
executables don't run on an armv6
iPhone 3G).
您还需要将 Architectures 设置为armv6
和armv7
。你不能直接还瞄准armv7s
。但是,这并不意味着您的应用程序不会在 iPhone 5 上运行。 armv7
可执行文件应该在 iPhone 5 上运行,只需在armv7s
. 只是兼容性在另一个方向上不起作用(例如,armv7
可执行文件不能在armv6
iPhone 3G上运行)。
There's also a step that might be necessary, that's notmentioned in chpwn's blog. You may get these warnings (which really are errors, because Xcode won't generate your executable properly):
还有一个可能是必要的步骤,chpwn 的博客中没有提到。您可能会收到这些警告(这确实是错误,因为 Xcode 不会正确生成您的可执行文件):
warning: no rule to process file '$(PROJECT_DIR)/main.m' of type sourcecode.c.objc for architecture armv6
警告:没有规则来处理架构 armv6 的 sourcecode.c.objc 类型的文件 '$(PROJECT_DIR)/main.m'
In order to fix this, you'll need to setup a custom Build Rulefor your target that tells Xcode to use LLVM GCC 4.2to generate armv6 code. Define the rule for files matching the pattern *.[mc]
:
为了解决这个问题,你需要为你的目标设置一个自定义构建规则,告诉 Xcode 使用LLVM GCC 4.2来生成 armv6 代码。为与模式匹配的文件定义规则*.[mc]
:
This will be a different compiler than the Xcode default, and you may need to adjust some of the syntax in your Objective-C code. Even though many people wanting to do this probably wrote their apps before ARC, it is important to note that LLVM gcc 4.2 does not support ARC.
这将是一个不同于 Xcode 默认的编译器,您可能需要调整 Objective-C 代码中的一些语法。尽管许多想要这样做的人可能在 ARC 之前编写了他们的应用程序,但重要的是要注意LLVM gcc 4.2 不支持 ARC。
Finally, you probably will still see warnings from Xcode about iOS deploy targets less than 4.3, and armv6
not being supported. Those, I found, were not problems, and could be ignored:
最后,您可能仍会看到来自 Xcode 的关于 iOS 部署目标低于 4.3 且armv6
不受支持的警告。我发现这些都不是问题,可以忽略:
Running lipo -info
on my app executable after this shows the desired result:
lipo -info
在这显示出所需的结果之后,在我的应用程序可执行文件上运行:
lipo -info MyAppName
Architectures in the fat file: MyAppName are: armv6 armv7
回答by Paul Lalonde
Xcode 4.5 makes iOS 4.3 the earliest supported operating system, which effectively orphans the original iPhone and the 3G.
Xcode 4.5 使 iOS 4.3 成为最早支持的操作系统,这有效地孤立了最初的 iPhone 和 3G。
If you want to support iOS versions earlier than 4.3, you will need to keep around a 4.4 version of Xcode.
如果您想支持 4.3 之前的 iOS 版本,则需要保留 4.4 版本的 Xcode。
To be a bit clearer : you cannot easily(meaning Xcode does not out-of-the-box) support pre-4.3 devices and use iOS 6 features in the same app. That's because iOS 6 features require XCode 4.5 which also sets iOS 4.3 as the minimum supported OS.
说得更清楚一点:你不能轻易地(意味着 Xcode 不是开箱即用的)支持 4.3 之前的设备并在同一个应用程序中使用 iOS 6 功能。这是因为iOS 6的功能需要的XCode 4.5,其还设置的iOS 4.3的最低支持的操作系统。
So, you have 3 choices :
所以,你有 3 个选择:
- Continue using XCode 4.4. You'll be able to target pre-4.3 iOS. You won't be able to take advantage of iOS 6 features, but your app should run fine on it assuming you perform adequate testing on actual iOS 6 devices.
- Migrate to XCode 4.5. You won't be able to target pre-4.3 iOS, but you'll be able to take advantage of iOS 6 features.
- Make two versions your app. Build one version with XCode 4.4 (as in option 1), and the other with 4.5 (as in option 2). From the point of view of distribution, these will be 2 separate apps, they'll each have their own bundle ID, etc. You will have two entries in the app store.
- 继续使用 XCode 4.4。您将能够针对 4.3 之前的 iOS。您将无法利用 iOS 6 的功能,但假设您在实际的 iOS 6 设备上执行了足够的测试,您的应用程序应该可以正常运行。
- 迁移到 XCode 4.5。您将无法在前目标4.3的iOS,但你可以采取的iOS 6的功能。
- 为您的应用制作两个版本。使用 XCode 4.4(如选项 1)构建一个版本,使用 4.5(如选项 2)构建另一个版本。从分发的角度来看,这将是 2 个独立的应用程序,每个应用程序都有自己的捆绑 ID 等。您将在应用程序商店中有两个条目。
If you are comfortable going beyond what is supported directly by Xcode, see Nate's answer.
如果您对超越 Xcode 直接支持的内容感到满意,请参阅 Nate 的回答。
回答by Scott Berrevoets
The original iPhone and iPhone 3G are the only devices that don't support iOS 5. The iPhone 3G is now 4 years old. You may want to consider dropping support for iOS 4. If you don't want to do that, I think you'll have to develop in two different versions of Xcode.
最初的 iPhone 和 iPhone 3G 是唯一不支持 iOS 5 的设备。 iPhone 3G 现在已经 4 岁了。您可能需要考虑放弃对 iOS 4 的支持。如果您不想这样做,我认为您必须在两个不同版本的 Xcode 中进行开发。
回答by Christian Fries
I assume that the dropped support for iOS 4.2.1 is not the core problem. In fact, I tried to work around this and do the following:
我认为对 iOS 4.2.1 的支持下降不是核心问题。事实上,我试图解决这个问题并执行以下操作:
- Build the app with iOS 6 SDK, setting deployment target to iOS 4.2.1 (which works).
- Pack the app for ad hoc installation and install the app on an iOS 4.2.1 device (iPod touch 2G).
- Test the app.
- 使用 iOS 6 SDK 构建应用程序,将部署目标设置为 iOS 4.2.1(有效)。
- 打包应用程序以进行临时安装并将应用程序安装在 iOS 4.2.1 设备 (iPod touch 2G) 上。
- 测试应用程序。
However, installation fails. The reason here is - afaik - not the iOS version. The reason is the architecture. XCode 4.5 no longer allows you to build for armv6. It only builds for armv7. On the other hand: all device which have armv7 or better can run iOS 5. The only devices which do not support armv7 are iPhone, iPhone 3G, iPod touch 1G and iPod touch 2G.
但是,安装失败。这里的原因是 - afaik - 不是 iOS 版本。原因在于架构。XCode 4.5 不再允许您为 armv6 构建。它仅适用于 armv7。另一方面:所有具有 armv7 或更高版本的设备都可以运行 iOS 5。唯一不支持 armv7 的设备是 iPhone、iPhone 3G、iPod touch 1G 和 iPod touch 2G。
So for me the question is: can you build for armv6 with XCode 4.5 and iOS 6 as base SDK?
所以对我来说,问题是:你能用 XCode 4.5 和 iOS 6 作为基础 SDK 为 armv6 构建吗?
Edit: Which you cannot do, because the iOS 6 base SDK is not available for armv6. Right?
编辑:您不能这样做,因为 iOS 6 基础 SDK 不适用于 armv6。对?
回答by matsoftware
I think that targeting to 4.3 is the best choice, according to ios version statistics
根据ios版本统计,我认为定位到4.3是最好的选择
回答by biii
Try to set the project settings manually using IPHONEOS_DEPLOYMENT_TARGET=4.0
. However, I don't know if there is any side effect.
尝试使用 手动设置项目设置IPHONEOS_DEPLOYMENT_TARGET=4.0
。不过不知道有没有副作用。