Xcode 4.5和iOS 4.2.1不兼容 [英] Xcode 4.5 and iOS 4.2.1 incompatibility

查看:111
本文介绍了Xcode 4.5和iOS 4.2.1不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最新的版本说明表示4.2.1和更低版本将不被支持,我们现在必须使用2版本的Xcode来开发时支持旧设备?如果我们想开发iOS6 AND支持4.2和更低版本,这将是很难支持旧设备。



我不认为Xcode 4.4会支持iOS6。所以这是问题。

解决方案

你可以这样做,但它需要一些小的Xcode黑客,和一些牺牲。根据支持iOS 6的意思,这可能不够或不够。如果你只是想让你的应用程序运行在iOS 6,那么这应该工作。如果你还需要你的应用程序结合新的iOS 6功能,那么它不会。



  (注意,对于使用多个版本的Xcode没有问题的其他人:此类似问题有答案允许您也使用新的iOS 6 API并直接定位到armv7)



查看关于chpwn的博客的基本说明(但阅读下面的其他内容)



基本上,你可以使用Xcode 4.5来构建iOS 4及以上版本,但是你不能利用新的iOS 6的功能。所以,你真正构建的iOS 4和5,并假设应用程序将运行良好的iOS 6(这应该是真的,但你需要自己测试)。



您需要复制iOS 5 SDK文件夹

  /Applications/Xcode.app/Contents/开发人员/平台/ iPhoneOS.platform / Developer / SDKs / iPhoneOS5。*。sdk 

安装(您需要暂时保存,或重新安装到非标准位置)。然后,您可以将Build Settings中的部署目标设置为iOS 4.0(或任何所需的最低操作系统)。您可能需要在文本编辑器中打开 project.pbxproj 文件以手动设置:

  IPHONEOS_DEPLOYMENT_TARGET = 4.0; 

您还需要将Architectures设置为 armv6 armv7 。您不能直接定位 armv7s 。但是,这并不意味着你的应用程序不会运行在iPhone 5. armv7 可执行文件应该运行在iPhone 5上,只是没有任何优化添加在 armv7s 。这只是因为兼容性不能在其他方向工作(例如 armv7 可执行文件不在 armv6 3G)。



p>

还有一个步骤,可能是必要的,这是在chpwn的博客中提到。你可能会得到这些警告(这真的是错误,因为Xcode不会正确地生成你的可执行文件):


警告:架构armv6类型为sourcecode.c.objc的文件'$(PROJECT_DIR)/main.m'


为了解决这个问题,您需要为目标设置一个自定义构建规则,告诉Xcode使用 LLVM GCC 4.2 生成armv6代码。定义符合模式 *。[mc] 的文件的规则:





这将是一个不同于Xcode默认的编译器,可能需要调整你的Objective-C代码中的一些语法。即使很多人想要这样做,可能在ARC之前写了他们的应用程序,重要的是要注意 LLVM gcc 4.2不支持ARC < a>。



最后,您可能仍然会看到Xcode中关于iOS部署目标少于4.3和 armv6 不支持。那些,我发现,不是问题,可以忽略:





在我的应用可执行文件上运行 lipo -info 结果:



胖胖文件中的架构:MyAppName是: armv6 armv7


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.

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?

解决方案

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.

    (Note for others who don't have a problem using multiple versions of Xcode: this similar question has answers that do allow you to also use new iOS 6 APIs and directly target armv7s)

See basic instructions on chpwn's blog here (but read the rest of this below, too!)

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

You'll need to copy the iOS 5 SDK folder

/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 Target in 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:

IPHONEOS_DEPLOYMENT_TARGET = 4.0;

You'll also need to set the Architectures to armv6 and armv7. You cannot directly also target 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).

There's also a step that might be necessary, that's not mentioned in chpwn's blog. You may get these warnings (which really are errors, because Xcode won't generate your executable properly):

warning: no rule to process file '$(PROJECT_DIR)/main.m' of type sourcecode.c.objc for architecture armv6

In order to fix this, you'll need to setup a custom Build Rule for your target that tells Xcode to use LLVM GCC 4.2 to generate armv6 code. Define the rule for files matching the pattern *.[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.

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:

Running lipo -info on my app executable after this shows the desired result:

lipo -info MyAppName
Architectures in the fat file: MyAppName are: armv6 armv7 

这篇关于Xcode 4.5和iOS 4.2.1不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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