安装新的 Xcode 版本后,旧的 SDK 消失了
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3000241/
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
Older SDK disappeared after installing new Xcode version
提问by elementsense
Why are old SDKs beeing removed when installing a new version of xcode with new Iphone SDK ? Now we have v4, what settings do I have to make in order that the apps still work with 3.x ?
为什么在使用新的 Iphone SDK 安装新版本的 xcode 时会删除旧的 SDK?现在我们有了 v4,我必须进行哪些设置才能使应用程序仍然可以与 3.x 一起使用?
Thanks
谢谢
采纳答案by zoul
Set the Base SDK to 4.0 and Deployment Target to 3.x. Or, in modern conditions, the Base SDK to Latest and Deployment Target to whatever you need.
将 Base SDK 设置为 4.0,将部署目标设置为 3.x。或者,在现代条件下,最新和部署目标的基础 SDK 可以满足您的任何需求。
回答by Vishal Chaudhry
Although 'Zoul' has most succinctly answered the question, I shall make an attempt to elaborate on the 2 settings and point to some useful documents which will help others who are new to the situation.
尽管“Zoul”已经最简洁地回答了这个问题,但我将尝试详细说明这 2 个设置并指出一些有用的文档,以帮助其他不熟悉这种情况的人。
Base SDK Version: This indicates the version of the SDK based on which the program has been compiled. This can be set from the "Build Settings" for the project or target. You can use API code from Apple in your code introduced up-to that version and compiler will know all the symbols and compile without any issues.
Deployment target: This is a declaration from your side about the minimum iOS version which should be installed on the user's device to run your code. This setting can be found under "Info" section for Project and "Summary" section for a particular target. Now, important thing to understand is that your code will not automatically run smoothly on devices with older versions of the iOS if you are using API code introduced in later version by Apple. These can be new classes/methods/frameworks introduced by Apple in later version. You have to ensure by writing necessary conditional code and provide alternate code path to gracefully degrade for older iOS version which does not have the newer API. It is up-to you to handle version incompatibilities.
Base SDK Version:表示编译程序所依据的SDK版本。这可以从项目或目标的“构建设置”中设置。您可以在引入到该版本的代码中使用来自 Apple 的 API 代码,编译器将知道所有符号并编译而不会出现任何问题。
部署目标:这是您方关于应安装在用户设备上以运行您的代码的最低 iOS 版本的声明。此设置可以在项目的“信息”部分和特定目标的“摘要”部分下找到。现在,需要了解的重要一点是,如果您使用的是 Apple 在更高版本中引入的 API 代码,那么您的代码将无法在装有旧版 iOS 的设备上自动流畅运行。这些可以是 Apple 在更高版本中引入的新类/方法/框架。您必须通过编写必要的条件代码并提供替代代码路径来确保为没有较新 API 的旧 iOS 版本优雅降级。由您来处理版本不兼容性。
Apple documentation on the subject can be found in "SDK Compatibility Guide".
关于这个主题的 Apple 文档可以在“ SDK 兼容性指南”中找到。
To know about the changes with different versions of iOS refer "What's new in iOS".
要了解不同版本的 iOS 的变化,请参阅“iOS 中的新功能”。
This topic is also discussed in "iOS Development Guide" under section "Building and Running Application". Refer sub-section "Specifying the Runtime Environment".
这个主题也在“ iOS 开发指南”中的“构建和运行应用程序”一节中讨论。请参阅“指定运行时环境”小节。
回答by Calin Drule
If you still have the problem after you set Deployment target at least as low as your desired SDK, then you need to download that SDK. Luckily, Xcode helps us here also:
如果在将部署目标设置为至少与所需的 SDK 一样低后仍有问题,则需要下载该 SDK。幸运的是,Xcode 也在这里帮助了我们:
- look after Simulator selector in top left of your Xcode and select More Simulators. It will open a page like the one below:
- 查看 Xcode 左上角的 Simulator 选择器,然后选择 More Simulators。它将打开一个如下所示的页面:
- just select the SDK you need to test your app against.
- 只需选择您需要用来测试您的应用程序的 SDK。
回答by SaltyNuts
If you have backups of your system from something like Time Machine (and you better!) you can copy the older SDKs from the backup located at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs - then just restart XCode and you're ready to go.
如果你有 Time Machine 之类的系统备份(你更好!),你可以从位于 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs 和 /Developer/Platforms/iPhoneSimulator.platform 的备份中复制旧的 SDK /Developer/SDKs - 然后只需重新启动 XCode,您就可以开始了。
回答by Allisone
3.2.3 last beta did remove all other SDK's cause to many people tried publish Apps developed with the beta SDK, which will not be accepted. I guess GM is doing still the same
3.2.3 上次测试版确实删除了所有其他 SDK 的原因,导致许多人尝试发布使用测试版 SDK 开发的应用程序,但不会被接受。我猜通用汽车还在做同样的事情
If you want to develop for 4.0,3.2 and 3.0 (plus 3.0,3.1,3.1.2,3.1.3) do the following
如果要为 4.0,3.2 和 3.0(加上 3.0,3.1,3.1.2,3.1.3)开发,请执行以下操作
- sudo /Developer/Library/uninstall-devtools –mode=all (This will uninstall the current XCode installation)
- Then install first old XCode (3.2 final) in default folder (/Developer)
- Then install the new XCode (3.2.3 GM) in other folder (/DeveloperBeta)
- This way you will have both. And can launch xcode from either /Developer/Applications/Xcode.app or /DeveloperBeta/Applications/Xcode.app
- sudo /Developer/Library/uninstall-devtools –mode=all (这将卸载当前的 XCode 安装)
- 然后在默认文件夹 (/Developer) 中安装第一个旧的 XCode (3.2 final)
- 然后在其他文件夹(/DeveloperBeta)中安装新的XCode(3.2.3 GM)
- 这样你就会两者兼得。并且可以从 /Developer/Applications/Xcode.app 或 /DeveloperBeta/Applications/Xcode.app 启动 xcode