在 Lion 中将旧的 iOS SDK 添加到 Xcode 4.1

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

Adding Older iOS SDKs to Xcode 4.1 in Lion

iosxcodeios4osx-lion

提问by Rafeed C.

I just installed Lion and Xcode 4.1. How do I add older SDKs so I can build and run in 4.1 or 4.2 in iPhone/iPad Simulator? Xcode 4.1 only comes with the iOS 4.3 SDK.

我刚刚安装了 Lion 和 Xcode 4.1。如何添加旧版 SDK,以便我可以在 iPhone/iPad Simulator 中的 4.1 或 4.2 中构建和运行?Xcode 4.1 仅随 iOS 4.3 SDK 一起提供。

Does Lion have some sort of minimum SDK for builds?

Lion 是否有某种用于构建的最低 SDK?

Thanks,

谢谢,

回答by nioq

Actually it ispossible to add older SDKs as long as you can still get your hands on an older version of Xcode with the older SDK. It's useful too sometimes: when you do this you get to find out about unsupported constants and methods you may be using during compile rather than at runtime. Here's how to do it.

其实这可以添加旧版SDK,只要你仍然可以得到你的手与旧的SDK旧版本的Xcode。有时它也很有用:当您这样做时,您会发现在编译期间而不是在运行时可能使用的不受支持的常量和方法。这是如何做到的。

  1. Get hold of an older version of Xcode with the older SDK. The Apple iOS Dev Center currently lists the 4.3 SDK with the Xcode 3.2.6 download.

  2. Mount the dmg and open up the Packages folder hidden within the dmg via Terminal:

    open /Volumes/Xcode\ and\ iOS\ SDK/Packages/

  3. Double click the pkg file for the SDK version you want. I was looking for iPhoneSDK4_3.pkg but, in addition to 4.3, found packages as old as iPhoneSDK3_0.pkg. So perhaps older SDKs may still be packaged with the App Store download if you know where to find it (I didn't).

  4. Let it install in it's own folder of choice since you won't be able to force it to install in Applications/Xcode.app/Contents/Developer (which is where the Developer folder is now)

  5. You'll find the package installed in the Platforms folder in the volume you chose. Move the relevant SDK over to the Developer folder within Xcode.app. You'll likely have to use sudo:

    sudo mv /Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

  6. Restart Xcode and you should see the new (old) SDK listed in your options for Base SDK. Yay!

  1. 使用旧版 SDK 获取旧版 Xcode。Apple iOS Dev Center 当前列出了带有 Xcode 3.2.6 下载的 4.3 SDK。

  2. 挂载 dmg 并通过终端打开隐藏在 dmg 中的 Packages 文件夹:

    打开 /Volumes/Xcode\ and\ iOS\ SDK/Packages/

  3. 双击所需 SDK 版本的 pkg 文件。我一直在寻找 iPhoneSDK4_3.pkg,但除了 4.3 之外,还找到了与 iPhoneSDK3_0.pkg 一样古老的软件包。因此,如果您知道在哪里可以找到它(我不知道),那么旧的 SDK 可能仍会与 App Store 下载一起打包。

  4. 让它安装在它自己选择的文件夹中,因为您将无法强制它安装在 Applications/Xcode.app/Contents/Developer(现在是 Developer 文件夹的位置)

  5. 您将在您选择的卷的 Platforms 文件夹中找到安装的包。将相关的 SDK 移到 Xcode.app 中的 Developer 文件夹。您可能必须使用 sudo:

    须藤 mv /Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

  6. 重新启动 Xcode,您应该会在 Base SDK 的选项中看到新的(旧的)SDK。好极了!

Update as of 12 Sep 2013

2013 年 9 月 12 日更新

If the "older SDK" you're trying to add comes bundled in Xcode 4.3 or later, adding the SDK is as simple as downloading Xcode from dev center link that says "Looking for an older version of Xcode?" (currently points here), mounting the dmg, then copying the relevant files over.

如果您尝试添加的“旧版 SDK”捆绑在 Xcode 4.3 或更高版本中,则添加 SDK 就像从开发中心链接下载 Xcode 一样简单,该链接显示“正在寻找旧版 Xcode?” (目前指向此处),挂载dmg,然后将相关文件复制过来。

In terminal, you'd do something like this (edit for the appropriate SDK version number):

在终端中,您可以执行以下操作(编辑相应的 SDK 版本号):

cp -R /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

For SDKs from versions of Xcode prior to 4.3, the older steps are still relevant.

对于 4.3 之前的 Xcode 版本的 SDK,旧的步骤仍然适用。

I found this happens to work for getting the Xcode 5 GM to compile builds that carry the old iOS 6 UI even when deployed on iOS 7 devices. Useful for fixing bugs pending a UI redesign. That said, there's got to be an easier way to get the iOS 6 UI on an iOS 7 device.

我发现这恰好适用于让 Xcode 5 GM 编译带有旧 iOS 6 UI 的构建,即使部署在 iOS 7 设备上也是如此。用于修复等待 UI 重新设计的错误。也就是说,必须有一种更简单的方法来在 iOS 7 设备上获取 iOS 6 UI。

回答by FeifanZ

You can't. What you can do, however, is click on the top-level entry in the File Navigator. It'll take you to the application settings. Go to the tab called Build Settings, and change the iOS Deployment Target to whatever version of iOS you'd like to support from (the earliest version you support).

你不能。但是,您可以做的是单击文件导航器中的顶级条目。它将带您进入应用程序设置。转到名为 Build Settings 的选项卡,并将 iOS 部署目标更改为您想要支持的任何 iOS 版本(您支持的最早版本)。

See "To Edit a Build Setting…": http://developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Building/Building.html#//apple_ref/doc/uid/TP40010215-CH9-SW5

请参阅“编辑构建设置...”:http: //developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Building/Building.html#//apple_ref/doc/uid/TP40010215-CH9- SW5

回答by 2cupsOfTech

Open Xcode and open Preferences (Xcode -> Preferences menu). Click the Downloads icon and look in the Components tab. All versions from 3.0 to 5.1 should be available. Just click Install for the ones you want to use.

打开 Xcode 并打开首选项(Xcode -> 首选项菜单)。单击下载图标并查看组件选项卡。从 3.0 到 5.1 的所有版本都应该可用。只需单击您要使用的安装。

回答by Brainware

None of these answers worked for me for Mac OS 10.8 and XCode 4.5. But now that things are installed under the Applications folder, it's much easier to manage.

这些答案都不适用于 Mac OS 10.8 和 XCode 4.5。但是现在东西都安装在 Applications 文件夹下,管理起来就容易多了。

Option #1: Keeping an older copy of XCode is easy to do by renaming it before you install the new one. Then you can use Product->Preform Action->Run Without Building on the new version to test on newer devices or newer simulators.

选项#1:通过在安装新版本之前重命名旧版本的 XCode,可以轻松保留旧版本的 XCode。然后你可以使用 Product->Preform Action->Run Without Building on the new version 在新的设备或新的模拟器上测试。

Option #2: If you REALLY want to build with older SDKs in the newer XCode, then you can simply copy over an SDK using finder. You'll need to have an older version of XCode installed under Applications for this to work. In the following example, I just renamed XCode 4.4 to XCode_old before I installed XCode 4.5. Note: You can right click on the .app file and choose Show Contents to get to these files or just use the cp from a terminal window.

选项#2:如果您真的想在较​​新的 XCode 中使用较旧的 SDK 进行构建,那么您可以使用 finder 简单地复制一个 SDK。您需要在应用程序下安装旧版本的 XCode 才能正常工作。在以下示例中,我只是在安装 XCode 4.5 之前将 XCode 4.4 重命名为 XCode_old。注意:您可以右键单击 .app 文件并选择“显示内容”以访问这些文件,或者仅使用终端窗口中的 cp。

from: /Applications/Xcode_old.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
to:   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

Then, iOS 5.1 will show up under Build Settings as a Bask SDK. You can do the same thing for simulators:

然后,iOS 5.1 将在 Build Settings 下显示为 Bask SDK。你可以对模拟器做同样的事情:

from: /Applications/Xcode_old.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk
to:   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/

回答by Aram Kocharyan

You have to run your application in the older version of Xcode that came coupled with the older iOS version. I have 3.2.5 installed under /Developer-3.2.5/. I have to say it's about 10 times faster than Xcode 4... You can download old versions here: http://iphonesdkdev.blogspot.com/2010/04/old-versions-of-iphone-sdk.html

您必须在与旧 iOS 版本相结合的旧版本 Xcode 中运行您的应用程序。我在/Developer-3.2.5/. 我不得不说它比 Xcode 4 快 10 倍......你可以在这里下载旧版本:http: //iphonesdkdev.blogspot.com/2010/04/old-versions-of-iphone-sdk.html

回答by jrtc27

You can't, but it will build fine for a device that is plugged in running an old version of iOS (what you should be conducting your proper testing on).

您不能,但是对于插入运行旧版本 iOS 的设备(您应该对其进行适当测试),它可以很好地构建。

回答by user899007

I had a similar issue in Xcode 4.02 for Snow Leopard using SDK 4.3. I wanted to test on an iPhone 3G, but iOS4.2 is the latest (and correct version) for that device. In order to 'see' and run on that device in the Scheme, I had to change the Build Settings for iOS Deployment Target as described above. (btw you also have to have restrictions on the iPhone turned off to let Xcode install the app :) )

我在使用 SDK 4.3 的雪豹的 Xcode 4.02 中遇到了类似的问题。我想在 iPhone 3G 上进行测试,但 iOS4.2 是该设备的最新(和正确版本)。为了在 Scheme 中“查看”并在该设备上运行,我必须如上所述更改 iOS 部署目标的构建设置。(顺便说一句,您还必须对 iPhone 进行限制才能让 Xcode 安装应用程序:))

回答by Pega88

In addition to Steven's answer, you can find older versions of XCode - including the older SDKs:

除了史蒂文的回答,您还可以找到旧版本的 XCode - 包括旧版 SDK:

Looking for an older version of Xcode?

正在寻找旧版本的 Xcode?