使用 Xcode 4.2 和 iOS 5 SDK 时是否可以针对较旧的 iOS 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7760946/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:08:09  来源:igfitidea点击:

Is it possible to target older iOS versions when using Xcode 4.2 and iOS 5 SDK?

iphonexcodeios5

提问by Greg Ellis

I just recently downloaded the Xcode 4.2 with iOS 5 SDK package and I immediately noticed that I am unable to use my iPhone 3Gs with iOS 4.2.1 for debugging. I am only able to debug and test on my iphone 4 with iOS 5 installed.

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

For any of my devices running any iOS less than 5.0 Xcode just says "Finished running for iPhone3GS" and doesn't run it. I have my deployment target set to 3.0 because I am not using any features in my app above 3.0 and I want to be able to target all versions 3.0 or higher. I have all my provisioning profiles installed and up to date.

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

I have quit and restarted xcode, I have cleaned the build multiple times. I have tried adding armv6 in the archtecture build settings, but nothing will allow me to build and run my app on my old phone with ios 4.2.1.

我已经退出并重新启动了 xcode,我已经多次清理构建。我曾尝试在架构构建设置中添加 armv6,但没有任何东西允许我在使用 ios 4.2.1 的旧手机上构建和运行我的应用程序。

My question is, is it possible to still make apps with the new SDK work for iOS versions lower than 5? How can I be sure that my app will still run on lower iOS versions if I am unable to install them on my old phone?

我的问题是,是否仍然可以使具有新 SDK 的应用程序适用于低于 5 的 iOS 版本?如果我无法在旧手机上安装我的应用程序,如何确保我的应用程序仍能在较低的 iOS 版本上运行?

Edit:OK it looks like iOS SDK 5 dropped support for armv6 by default. What you have to do is add armv6 in the Architectures field under Build Settings for both your Target and your Project. Then your app will be able to run on iPhone 3G devices. Answer can be found here How to build for armv6 and armv7 architectures with iOS 5

编辑:好的,看起来 iOS SDK 5 默认放弃了对 armv6 的支持。您需要做的是在您的目标和项目的构建设置下的架构字段中添加 armv6。然后您的应用程序将能够在 iPhone 3G 设备上运行。可以在此处找到答案 How to build for armv6 and armv7 architecture with iOS 5

回答by mmorris

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.

我在尝试在 iPhone 3G 4.2.1 上运行新创建的 Xcode 4.2 项目时遇到了同样的问题。这是我如何让它运行。

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

1)将目标的“构建设置”==>“架构”从“标准(armv7)”更改为“其他”。添加 armv6 和 armv7。

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

2) 将目标的“构建设置”==>“有效架构”更改为 armv6 和 armv7。

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

3) 将目标的“构建设置”==>“iOS 部署目标”更改为 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

4)打开项目*-Info.plist,去掉“Required device capabilities”设置(注意需要armv7) 在此处输入图片说明

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

无法安装应用程序

/Users/.../TestsDebug.app 中应用程序的 Info.plist 指定了 Dev iPhone 3G 不满足的设备功能要求

All should work after that. Talk about a PITA.

一切都应该在那之后工作。谈论 PITA。

回答by Aleksejs Mjaliks

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

转到Xcode > Preferences > Downloads并安装对旧 iOS 版本的调试支持。

回答by flizit

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.

mmorris 让我接近解决问题...在 Info.plist 中,我必须将所需的设备功能设置为 armv6,而不是 armv7 希望这也能帮助其他人。

回答by Greg

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!

我发现我必须将 armv6 添加到架构中,但仍然不起作用。现在我已经从所需的功能中删除了 armv7,就是这样!有效!

回答by otto

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.

我在尝试在旧的 iPod Touch 上运行我的应用程序时遇到了类似的问题。我升级到 Xcode 4.3.3,该应用程序将不再在调试器中为我在旧硬件上运行。

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.

就我而言,我发现构建方案是罪魁祸首。Xcode 4.3.3 在升级我的项目时提示我从 GDB 调试器切换到 LLDB。当我将方案的 Run 操作更改回 GDB 时,我能够从 Xcode 在我的旧硬件上再次运行该应用程序。

回答by Foo Bah

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

您需要连接手机,然后转到组织者。Xcode 应该自动请求旧版本。

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

有关更多信息,请参阅开发人员页面。它在 4.2 测试版的注释中有所描述

回答by Tom Boutell

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:

这对我有用,如果你以前有一个旧版本的 Xcode,它应该对你有用。如果没有,那么您应该按照其他人的建议从旧版本的 SDK 中获取 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

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.

此命令与其他命令显示的命令略有不同,但这些命令为我删除了 SDKs 文件夹中的文件 - 我们希望使用适当的名称创建它的子目录。

回答by Arkady

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.

希望它会帮助别人。