当使用 Xcode 4.2和 iOS 5 SDK 时,是否有可能针对旧的 iOS 版本?

我最近刚刚下载了 Xcode 4.2和 iOS 5 SDK 软件包,我立即注意到我无法使用我的 iPhone 3Gs 和 iOS 4.2.1进行调试。我只能在安装了 iOS5的 iPhone4上进行调试和测试。

对于任何运行 iOS 小于5.0的设备,Xcode 只是说“已经运行完 iPhone3GS”,而不运行它。我将部署目标设置为3.0,因为我没有在3.0以上的应用程序中使用任何功能,我希望能够针对所有版本的3.0或更高版本。我已经安装了所有的供应配置文件,并且是最新的。

我已经退出并重新启动 xcode,我已经清理了构建多次。我已经尝试过在架构构建设置中添加 armv6,但是没有什么能让我用 ios 4.2.1在我的旧手机上构建和运行我的应用程序。

我的问题是,有没有可能让新版 SDK 的应用程序在 iOS 版本低于5的情况下仍然可以工作?如果我不能在我的旧手机上安装它们,我怎么能确定我的应用程序仍然可以在较低的 iOS 版本上运行呢?

编辑: 好吧,看起来 iOSSDK5默认放弃了对 armv6的支持。您需要做的是将 armv6添加到您的目标和项目的“构建设置”下的“架构”字段中。然后你的应用程序就可以在 iPhone 3G 设备上运行了。 答案可以在这里找到 如何使用 iOS 5 为 armv6和 armv7架构构建

51044 次浏览

You need to connect the phone and then go to the organizer. Xcode should automatically request the older version.

See the developer page for more info. It was described in the notes for the 4.2 beta

Go to Xcode > Preferences > Downloads and install debugging support for older iOS versions.

I was having the same issue trying to get a newly created Xcode 4.2 project running on an iPhone 3G 4.2.1. Here is how I was able to get it to run.

1) Change the Target's "Build Settings" ==> "Architecture" from "Standard (armv7)" to "other". Add armv6 and armv7.

2) Change the Target's "Build Settings" ==> "Valid Architecture" to armv6 and armv7.

3) Change the Target's "Build Settings" ==> "iOS Deployment Target" to iOS 4.2.

enter image description here

4) Open the projects *-Info.plist, remove the setting "Required device capabilities" (note it required armv7) enter image description here

btw I figured this out when I tried to manually add the app via the organizer and it reported:

Can't install application

The Info.plist for application at /Users/.../TestsDebug.app specifies device capability requirements, which are not met by Dev iPhone 3G

All should work after that. Talk about a PITA.

mmorris got me close to resolving the issue... In the Info.plist, I had to set the Required Device Capabilities to armv6, not armv7 Hope this helps others out as well.

I found out that I had to add armv6 to architectures, but still did not work. And now I have removed armv7 from required capabilities, and that was it! It worked!

I encountered a similar problem trying to run my app on an old iPod Touch. I upgraded to Xcode 4.3.3 and the app would no longer run in the debugger for me on older hardware.

I believe the other comments here about "Architectures" and "Required device capabilities" are important details to specify correctly. Unfortunately, they weren't enough to fix my problem.

In my case, I found the build scheme to be the culprit. Xcode 4.3.3 prompted me to switch from the GDB debugger to LLDB when it upgraded my project. When I changed the Run action of my scheme back to GDB, I was able to run the app again on my old hardware from Xcode.

This worked for me and should work for you if you had an older version of Xcode previously. If not then you should follow the advice given by others to obtain the SDK from an older version of SDK:

sudo cp -a /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk

This command is only a little bit different from that shown by others, but those commands dropped the files in the SDKs folder itself for me - we want a subdirectory of it to be created with the appropriate name.

In my case there was a redundant line in Required device capabilities enter image description here

I just removed it...

enter image description here

Hopefully it will help someone else.