是否可以在 Xcode 5 上安装 iOS 6 SDK?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18423896/
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
Is it possible to install iOS 6 SDK on Xcode 5?
提问by Tony
Xcode 5 has a preferences pane that allow one to download iPhone 6.1 simulator, however I can't find a place where it allows downloading of iOS 6 SDK, thus it is not possible to set the active SDK to iOS 6 when developing with Xcode 5. Is there a workaround that would allow Xcode 5 to install iOS 6 SDK?
Xcode 5 有一个允许下载 iPhone 6.1 模拟器的首选项面板,但是我找不到允许下载 iOS 6 SDK 的地方,因此在使用 Xcode 5 开发时无法将活动 SDK 设置为 iOS 6 . 是否有允许 Xcode 5 安装 iOS 6 SDK 的解决方法?
EDIT:
编辑:
Workarounds should no longer be necessary now that Xcode 5 is generally available and allows you to download previous versions of the SDK.
现在 Xcode 5 已普遍可用并允许您下载 SDK 的早期版本,因此不再需要变通方法。
采纳答案by Rob Napier
EDIT: Starting Feb 1, 2014, Apple will no longer accept pre-iOS7 apps for submission to App Store. So while this technique still works, it will not be useful for most readers.
编辑:从 2014 年 2 月 1 日开始,Apple 将不再接受 iOS7 之前的应用程序提交到 App Store。因此,虽然这种技术仍然有效,但它对大多数读者来说没有用处。
Yes, this is fine. I still build with iOS 4.3 for one project (it's been awhile since we updated; but they still accepted it after iOS 6 came out), and I currently build 10.5 apps with Xcode 5.
是的,这很好。我仍然使用 iOS 4.3 为一个项目构建(自从我们更新以来已经有一段时间了;但在 iOS 6 发布后他们仍然接受了它),并且我目前使用 Xcode 5 构建 10.5 应用程序。
See How to point Xcode to an old SDK so it can be used as a "Base SDK"?for details on how to set it up. You can use my fix-xcodescript to link everything for you every time you upgrade.
请参阅如何将 Xcode 指向旧 SDK,以便将其用作“基础 SDK”?有关如何设置的详细信息。 每次升级时,您都可以使用我的fix-xcode脚本为您链接所有内容。
The only trick is getting the old SDKs. If you don't have them, you generally need to download old versions of Xcode (still available on developer.apple.com), open the installer package, and hunt around to find the SDK you need.
唯一的技巧是获取旧的 SDK。如果你没有它们,你通常需要下载旧版本的 Xcode(仍然可以在developer.apple.com 上找到),打开安装程序包,然后四处寻找你需要的 SDK。
SDKs can be found within the installer package at:
SDK 可以在安装程序包中找到:
Xcode.app/Contents/Developer/Platforms/
Xcode.app/Contents/Developer/Platforms/
回答by AvtarSingh Suchariya
I was also running the same problem when I updated to xcode 5 it removed older sdk. But I taken the copy of older SDK from another computer and the same you can download from following link.
当我更新到 xcode 5 时,我也遇到了同样的问题,它删除了旧的 sdk。但是我从另一台计算机上获取了旧 SDK 的副本,您可以从以下链接下载相同的副本。
http://www.4shared.com/zip/NlPgsxz6/iPhoneOS61sdk.html
(www.4shared.com test account [email protected]/test)
http://www.4shared.com/zip/NlPgsxz6/iPhoneOS61sdk.html(www.4shared.com
测试账号 [email protected]/test)
There are 2 ways to work with.
有 2 种方法可以使用。
1) Unzip and paste this folder to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs & restart the xcode.
1) 将此文件夹解压并粘贴到 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs 并重新启动 xcode。
But this might again removed by Xcode if you update xcode.
但是,如果您更新 xcode,这可能会再次被 Xcode 删除。
2) Another way is Unzip and paste where you want and go to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs and create a symbolic link here, so that the SDK will remain same even if you update the Xcode.
2)另一种方法是解压缩并粘贴到您想要的位置,然后转到 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs 并在此处创建符号链接,以便 SDK 将保持不变,即使你更新Xcode。
Another change I made, Build Setting > Architectures > standard (not 64) so list all the versions of Deployment Target
我做的另一个更改,构建设置 > 架构 > 标准(不是 64)所以列出部署目标的所有版本
No need to download the zip if you only wanted to change the deployment target.
如果您只想更改部署目标,则无需下载 zip。
Here are some screenshots.
这是一些屏幕截图。
回答by Jason Lee
Yes, I just solved the problem today.
是的,我今天刚刚解决了这个问题。
- Find the SDK file, like iPhoneOS6.1.sdk, in your or your friend's older Xcode directory.
- Copy & put it into the Xcode 5 directory : /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs.
- 在您或您朋友的旧 Xcode 目录中找到 SDK 文件,例如 iPhoneOS6.1.sdk。
- 复制并放入 Xcode 5 目录:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs。
Then you can choose the SDK like below :
然后您可以选择如下所示的 SDK:
Hope this helps you.
希望这对你有帮助。
回答by karim
Find and download old SDK. Older SDKs are found here.
查找并下载旧的 SDK。较旧的 SDK 可在此处找到。
I have copied the xcode.app directory as Xcode_4.6.3.app.
我已将 xcode.app 目录复制为 Xcode_4.6.3.app。
Now you can test and debug in both xcode versions. You have to run them from the corresponding folders or create shortcuts in your desktop. When building from command line give the parameter as iPhoneOS6.1
instead of iPhoneOS7.0
现在您可以在两个 xcode 版本中进行测试和调试。您必须从相应的文件夹中运行它们或在桌面上创建快捷方式。从命令行构建时,将参数作为iPhoneOS6.1
而不是iPhoneOS7.0
This worked great for me in Xcode5 and iOS.
这在 Xcode5 和 iOS 中对我很有用。
Go to into Xcode5's SDK dir. Its usually located at:
进入 Xcode5 的 SDK 目录。它通常位于:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
Add a symbolic link to the old SDK like this:
向旧 SDK 添加符号链接,如下所示:
sudo ln -s /Applications/Xcode_4.6.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk iPhoneOS6.1.sdk
Or more accurately from anywhere in the command line,
或者更准确地说,从命令行的任何地方,
sudo ln -s /Applications/Xcode_4.6.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
回答by unspokenblabber
You can download the older SDK and install it in
您可以下载旧版 SDK 并将其安装在
Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
folder. Logout + Login just to make sure the changes take effect and you should see the older SDK in your new XCode
文件夹。注销 + 登录只是为了确保更改生效,您应该在新的 XCode 中看到旧的 SDK
回答by Smikey
Just to add, you can actually download old versions of the simulator with Xcode 5 itself - just go to preferences and you'll find them under Downloads:
补充一点,您实际上可以使用 Xcode 5 本身下载旧版本的模拟器 - 只需转到首选项,您就会在下载下找到它们:
回答by Daniel C.
Just for me the easiest solution:
对我来说最简单的解决方案:
- Locate an older SDK like for example "iPhoneOS6.1 sdk" in an older version of xcode for example.
If you haven't, you can downlad it from Apple Developer server at this address:
https://developer.apple.com/downloads/index.action?name=XcodeWhen you open the xcode.dmg you can find it by opening the Xcode.app (right click and "show contents")
and go to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1 sdk
- Simple Copy the folder iPhoneOS6.X sdk and paste it in your xcode.app
- right click on your xcode.app in Applications folder.
- Go to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
- Just paste here.
- 例如,在较旧版本的 xcode 中找到较旧的 SDK,例如“iPhoneOS6.1 sdk”。如果你还没有,你可以在这个地址从 Apple Developer 服务器下载它:
https://developer.apple.com/downloads/index.action?name=Xcode当你打开 xcode.dmg 你可以通过打开找到它Xcode.app(右键单击并“显示内容”)并转到 Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1 sdk
- 简单复制文件夹 iPhoneOS6.X sdk 并将其粘贴到您的 xcode.app 中
- 右键单击 Applications 文件夹中的 xcode.app。
- 转到 Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
- 贴在这里就行了。
- Close your xcode app and re-open it again.
- 关闭您的 xcode 应用程序并重新打开它。
To test an app in iOS 6 on your simulator:
- Just choose iOS 6.0 in your active sheme.
要在模拟器上测试 iOS 6 中的应用程序: - 只需在活动主题中选择 iOS 6.0。
To build your app in iOS 6, so the design of your app will be the older design on an iPhone with iOS 7 also: - Choose iOS6.1 in Targets - Base SDK
要在 iOS 6 中构建您的应用程序,您的应用程序的设计也将是具有 iOS 7 的 iPhone 上的旧设计: - 在 Targets 中选择 iOS6.1 - Base SDK
Just note : When you change the base SDK in your Targets, iOS 7.0 won't be available anymore for building on the simulator !
请注意:当您更改目标中的基本 SDK 时,iOS 7.0 将不再可用于在模拟器上构建!
回答by autremoi
- Download Xcode 4.6.x from the Apple Dev Center: https://developer.apple.com/downloads/index.action
- Create a folder called Xcode4 within the Applications folder and drag-n-drop the downloaded dmg there.
Open a terminal window
$sudo cp -R /Applications/Xcode4/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
You will be prompt to enter a password since you're inside a system folder
- Open Xcode 5 and you should now see both SDKs
- 从 Apple Dev Center 下载 Xcode 4.6.x:https: //developer.apple.com/downloads/index.action
- 在 Applications 文件夹中创建一个名为 Xcode4 的文件夹,然后将下载的 dmg 拖放到那里。
打开终端窗口
$sudo cp -R /Applications/Xcode4/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
由于您在系统文件夹中,系统将提示您输入密码
- 打开 Xcode 5,您现在应该可以看到两个 SDK
回答by MadNik
Can do this, But not really necessary
可以这样做,但不是真的有必要
How to do this
这该怎么做
Jason Lee got the answer. When installing xCode I preferred keeping previous installations rather than replacing them. So I have these in my installation Folder
杰森·李得到了答案。在安装 xCode 时,我更喜欢保留以前的安装而不是替换它们。所以我的安装文件夹中有这些
So /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
Contain different sdks. (Replace Xcode.app with correct number) copy previous sdks to
所以/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
包含不同的sdks。(用正确的数字替换 Xcode.app)将以前的 sdks 复制到
/Applications/Xcode 3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
/Applications/Xcode 3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
Here is my folder after I copied one.
这是我复制后的文件夹。
Now restart xCode and you can set previous versions of sdks as base sdk.
现在重新启动 xCode,您可以将以前版本的 sdk 设置为基础 sdk。
Why it is not necessary
为什么没有必要
Refering Apple Documentaion
参考 Apple 文档
To use a particular SDK for an Xcode project, make two selections in your project's build settings.
要将特定 SDK 用于 Xcode 项目,请在项目的构建设置中进行两个选择。
Choose a deployment target.
This identifies the earliest OS version on which your software can run.
Choose a base SDK
Your software can use features available in OS versions up to and including the one corresponding to the base SDK. By default , Xcode sets this to the newest OS supported by Xcode.
选择一个部署目标。
这标识了您的软件可以运行的最早操作系统版本。
选择基础 SDK
您的软件可以使用操作系统版本中可用的功能,包括与基础 SDK 对应的版本。默认情况下,Xcode 将此设置为 Xcode 支持的最新操作系统。
Rule is Use latest as base SDK and set deployment target to the minimum version app supposed to run
规则是使用最新作为基础 SDK 并将部署目标设置为应该运行的最低版本应用程序
For example you can use iOS 7 as base sdk and set iOS 6 as deployment target. Run on iOS 6 simulator to test how it works on iOS 6. Install simulator if not available with list of simulators.
例如,您可以使用 iOS 7 作为基础 sdk,并将 iOS 6 设置为部署目标。在 iOS 6 模拟器上运行以测试它在 iOS 6 上的工作方式。如果模拟器列表不可用,请安装模拟器。
Additionaly You can unconditionally use features upto iOS 6. And Conditionally you can support new features of iOS 7 for new updated devices while supporting previous versions.
此外,您可以无条件地使用 iOS 6 之前的功能。并且有条件地您可以在支持以前版本的同时支持 iOS 7 的新更新设备的新功能。
This can be done using Weakly Linked Classes,Weakly Linked Methods, Functions, and Symbols
这可以使用弱链接类、弱链接方法、函数和符号来完成
Weak Linking
弱链接
Suppose in Xcode you set the deployment target (minimum required version) to iOS6 and the target SDK (maximum allowed version) to iOS7. During compilation, the compiler would weakly link any interfaces that were introduced in iOS7 while strongly linking earlier interfaces. This would allow your application to continue running on iOS6 but still take advantage of newer features when they are available.
假设在 Xcode 中,您将部署目标(所需的最低版本)设置为 iOS6,将目标 SDK(允许的最大版本)设置为 iOS7。在编译期间,编译器会弱链接 iOS7 中引入的任何接口,同时强链接早期的接口。这将允许您的应用程序继续在 iOS6 上运行,但仍然可以利用可用的更新功能。
回答by nioq
The other answers here are correct too, but I find the following steps to be the easiest:
这里的其他答案也是正确的,但我发现以下步骤是最简单的:
Just download Xcode 4.6.3 from the dev center link that says "Looking for an older version of Xcode?" (currently points here) and mount the dmg.
只需从“正在寻找旧版本的 Xcode?”的开发中心链接下载 Xcode 4.6.3。(当前指向此处)并安装 dmg。
Then in terminal, copy the SDK files over:
然后在终端中,复制 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/
Finally, relaunch Xcode and you're done.
最后,重新启动 Xcode,你就完成了。