有没有办法在 Xcode 中安装旧的 iOS SDK?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7320235/
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 there a way to install older iOS SDKs in Xcode?
提问by Oliver
I'd like to ensure some backward compatibility for my apps by compiling them using the older SDKs to test for newer classes and methods. However, Xcode is only available with SDKs for the latest iOS versions.
我想通过使用较旧的 SDK 编译我的应用程序来测试较新的类和方法来确保它们的向后兼容性。但是,Xcode 仅适用于最新 iOS 版本的 SDK。
I've downloaded and installed the iOS 3.1.3 SDK (using the method described here) and that works fine. My code is full (not so full :-) ) of __IPHONE_OS_VERSION_MAX_ALLOWED, __IPHONE_OS_VERSION_MIN_REQUIRED and such respondsToSelector.
我已经下载并安装了 iOS 3.1.3 SDK(使用这里描述的方法)并且工作正常。我的代码是 __IPHONE_OS_VERSION_MAX_ALLOWED、__IPHONE_OS_VERSION_MIN_REQUIRED 和这样的respondsToSelector 的完整(不是那么完整:-))。
This works right now for the iOS 3.1.3 SDK, but what if in the future I wanted to repeat this process with the 4.0 SDK? Is there a general process for installing older SDK versions in the latest Xcode?
这现在适用于 iOS 3.1.3 SDK,但如果将来我想用 4.0 SDK 重复这个过程怎么办?是否有在最新的 Xcode 中安装旧 SDK 版本的一般过程?
回答by hotpaw2
You can't install old 3.1 SDKs on Xcode 4. You can set the Deployment target lower to allow testing on devices running older OS versions than your current SDK installation. The only current way to completely ensure backward compatibility, while running more recent versions of Xcode, is to keep a device that runs iOS 3.x, and test on that device. (...because it is claimed that the old Simulators/tools sometimes actually allows APIs that won't run on an actual device with an OS of the same version).
您不能在 Xcode 4 上安装旧的 3.1 SDK。您可以将部署目标设置得更低,以允许在运行比当前 SDK 安装更旧的操作系统版本的设备上进行测试。在运行更新版本的 Xcode 的同时,完全确保向后兼容性的唯一当前方法是保留运行 iOS 3.x 的设备,并在该设备上进行测试。(...因为据说旧的模拟器/工具有时实际上允许无法在具有相同版本操作系统的实际设备上运行的 API)。
Other methods include installing the different versions of iOS developer tools in a separate Developer_XYZ directories, and or keeping around a bootable HD with the older iOS developer tool installation (say Snow Leopard with Xcode 3.x, since Lion might only support running Xcode 4.x).
其他方法包括在单独的 Developer_XYZ 目录中安装不同版本的 iOS 开发人员工具,和/或保留带有较旧 iOS 开发人员工具安装的可引导 HD(例如使用 Xcode 3.x 的 Snow Leopard,因为 Lion 可能仅支持运行 Xcode 4。 X)。
回答by Mustafa
For whatever reason (I had to do it to debug an Apple bug), if you still need to install an older SDK to your existing Xcode, follow these steps :
无论出于何种原因(我不得不这样做以调试 Apple 错误),如果您仍需要将旧版 SDK 安装到现有 Xcode,请按照以下步骤操作:
- Install the older Xcode package
- Copy the older Xcode SDK to the new Xcode Example (/old/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk to /new/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs)
- Restart your 'new' Xcode
- You will see the old SDK in the build setting option (base sdk)
- 安装旧的 Xcode 包
- 将旧的 Xcode SDK 复制到新的 Xcode 示例(/old/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk 到 /new/Xcode.app/Contents/Developer/Platforms /iPhoneOS.platform/Developer/SDKs)
- 重新启动你的“新”Xcode
- 您将在构建设置选项(基础 sdk)中看到旧的 SDK