如何在无需重新下载 Xcode 的情况下更新 iPhone SDK?

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

How to update iPhone SDK without having to re-download Xcode?

xcodeiphone-sdk-3.0

提问by Graeme

Silly question - Is there a way to download the iPhone SDK without Xcode when Apple releases an update?

愚蠢的问题 - 当 Apple 发布更新时,有没有办法在没有 Xcode 的情况下下载 iPhone SDK?

采纳答案by Seidr

As far as I understand you cannot download the SDK separately - and even if you could, I wouldn't recommend it. Using the bundled SDK+Xcode release is the best idea in my opinion, as it will be working for you out of the box. I know it's annoying having to download such a large amount of data for an SDK (not all of us have 100mbps pipes to play with!) but for ease of development, it's the way I'd recommend you go.

据我所知,您不能单独下载 SDK - 即使可以,我也不推荐它。在我看来,使用捆绑的 SDK+Xcode 版本是最好的主意,因为它开箱即用。我知道必须为 SDK 下载如此大量的数据很烦人(并非我们所有人都有 100mbps 的管道可以玩!)但为了便于开发,我建议您采用这种方式。

回答by Billy Brown

For those who have installed Xcode but do not have the iOS SDK, here is the way to download it without re-downloading Xcode: Got to

对于那些已经安装了 Xcode 但没有 iOS SDK 的人,这里是下载它而无需重新下载 Xcode 的方法:Got to

Xcode > Preferences > Downloads

Xcode > 首选项 > 下载

and select whatever you want to install.

并选择您要安装的任何内容。

回答by 0xcaff

Yes, contrary to what others say this is somewhat possible.

是的,与其他人所说的相反,这在某种程度上是可能的。

Method One

方法一

With this method you can download any iOS or OSX SDK and install it to XCode. Download the desired SDK, bundled with XCode, from developer.apple.com/downloads

使用此方法,您可以下载任何 iOS 或 OSX SDK 并将其安装到 XCode。从developer.apple.com/downloads下载所需的 SDK,与 XCode 捆绑在一起

Downloading XCode with SDK

使用 SDK 下载 XCode

Once the package is done downloading mount the disk image. Right on the XCode application in the image and click on Show Package Contents. Navigate to:

完成包下载后,挂载磁盘映像。就在图像中的 XCode 应用程序上,然后单击“显示包内容”。导航:

/Contents/Developer/Platforms/

/内容/开发人员/平台/

the iOS SDKs are in:

iOS SDK 位于:

iPhoneOS.platform/Developer/SDKs/ iOS SDKs

iPhoneOS.platform/Developer/SDKs/ iOS SDK

the OSX SDKs are in:

OSX SDK 位于:

MacOSX.platform/Developer/SDKs/

MacOSX.platform/Developer/SDKs/

and the iOS simulator SDKs are in:

iOS 模拟器 SDK 位于:

iPhoneSimulator.platform/Developer/SDKs/

iPhoneSimulator.platform/Developer/SDKs/

To install one of the SDKs simply find XCode.app and place the SDK in the appropriate folder of the XCode.app package.

要安装其中一个 SDK,只需找到 XCode.app 并将 SDK 放在 XCode.app 包的相应文件夹中。

Method Two

方法二

With this method you can only dowload iOS simulators and iOS simulator SDKs.

这种方法只能下载iOS模拟器和iOS模拟器SDK。

Open XCode and in the menu bar click on XCode > Preferences. In the preferences dialog select the downloads tab and select the simulators you would like to dowload.

打开 XCode 并在菜单栏中单击 XCode > 首选项。在首选项对话框中选择下载选项卡并选择您想要下载的模拟器。

Imgur

伊格

回答by Dan Story

Unfortunately, no. Apple only provides the SDK as a bundled package.

抱歉不行。Apple 仅以捆绑包的形式提供 SDK。

回答by JonB

They quite often include fixes and updates in the bundled version of xcode. I guess this is a good way for them to "force" people to use the latest point release of xcode.

它们经常在 xcode 的捆绑版本中包含修复和更新。我想这是他们“强制”人们使用最新版本的 xcode 的好方法。

回答by sanvital

The answer to the question being asked is, I think, that it is not possible. However, there is a highly related question (with a more interesting answer), how to use different/nonresident iOS SDKs with a particular version of Xcode? This does require downloading some otherXcode (to gain access to some otheriOS SDK).

所问问题的答案是,我认为这是不可能的。但是,有一个高度相关的问题(有一个更有趣的答案),如何在特定版本的 Xcode 中使用不同的/非常驻的 iOS SDK?这确实需要下载其他一些Xcode(以访问其他一些iOS SDK)。

This issue has been a passion of mine for approximately the last 10 years, since I enjoy the stability of (or, at least, predictability of known misbehaviors in) a familiar IDE (i.e. Xcode) version. I last investigated the solution to this issue 3 years ago, and it was slightly more involved than the solution from 5 or so years before that. Here are my notes, from 2017:

大约在过去的 10 年里,这个问题一直是我的热情所在,因为我喜欢熟悉的 IDE(即 Xcode)版本的稳定性(或者,至少,已知错误行为的可预测性)。我上次研究这个问题的解决方案是在 3 年前,它比 5 年前的解决方案稍微复杂一些。以下是我 2017 年的笔记:

SDK

开发工具包

  • What the development environment treats as the target device, e.g. compilation, IDE behaviors like displaying interface definitions/headers and code completion).
  • The "Base SDK" (in the "Build Settings" of a target in a project, which is possibly contained by a workspace) setting defaults to "Latest iOS", which resolves to a specific iOS version based on the contents of the Xcode app package directory
    • <app-package>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
    • A version of the Xcode application will ship (via Mac App Store or a disk image from developer.apple.com) with only one SDK. The above path will contain a directory named iPhoneOS.sdk and an alias (symbolic link) targeting this directory that is named according to the SDK version (iPhoneOS10.0.sdk -> iPhoneOS.sdk)
  • No application-provided means (i.e. preference of other UI affordance) for altering this characteristic.
    • While the plural form of the directory name (SDKs) seems like a vexing/mocking choice, you can modify the contents of this intra-app-package directory to include symbolic links to SDKs contained in other versions of Xcode.
    • This appears to only work in the forward direction, i.e. using a newer SDK in an older Xcode (e.g. iOS 10 SDK in Xcode 7). This direction has always met my historical needs. Only recently have I attempted to go backwards (make a newer Xcode use an older SDK, e.g. iOS 8.4 SDK in Xcode 7), and I discovered that recent Xcode installs (versions 8.0 and 7.3.1 on a 10.11.6 system) ignore symbolic links to older SDKs (i.e. they do not appear in a target's Base SDK popup menu – screen shot of Xcode 7.3.1 ignoring the iOS 8.4 SDK symlink).
      • UPDATE(new details): I double-checked my home machine (which I had used for additional multi-SDK experiments) and found that older SDKs do appear in the Base SDK popup. Mysterious! This is a 10.10.5 system, running Xcode 7.2.1 (which ships with iOS 9.2 SDK), editing a different (non-iovation) Xcode project, and the iOS 8.2 SDK (from Xcode 6.2) will display in the popup. Obviously, there are numerous differences between the setup, and I have no idea which variables cause the difference in behavior.
        • MYSTERY SOLVED: Recent Xcode installs (the aforementioned versions 8.0 and 7.3.1) include a MinimumSDKVersionkey in the …/iPhoneOS.platform/Info.plistfile. This key appears to be set to the SDK that ships with Xcode (i.e. inside the app package), and, consequently, blocks Xcode from recognizing older SDKs. I was first keyed onto this minimum-version mechanism from the xcodebuild command-line tool, which was printing out, "Skipped SDK <sdk-path>; its version (8.4) is below required minimum (10.0) for the iphoneos platform."
        • Editing MinimumSDKVersionplist key (e.g. making it 8.0) allows for the display and selection of older SDKs!
  • The fact that Apple rigidly binds SDK version to Xcode version has always bothered me. Oftentimes, I would prefer to add an SDK to an existing Xcode install, rather than updating the entire Xcode environment simply to gain support for a new version of iOS. Admittedly, bringing everything along in lock-step fashion (app, tools, device and OS support) does seem like it should simplify support issues for Apple, and, perhaps, they believe this conjoined progression also simplifies things for 3rd party devs (no options to fret over, just update the app).
  • 开发环境将什么视为目标设备,例如编译、IDE 行为(如显示接口定义/标头和代码完成)。
  • “Base SDK”(在项目中目标的“Build Settings”中,可能包含在工作区中)设置默认为“Latest iOS”,它根据 Xcode 应用程序的内容解析为特定的 iOS 版本包目录
    • <app-package>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
    • Xcode 应用程序的一个版本将只带有一个 SDK(通过 Mac App Store 或来自 developer.apple.com 的磁盘映像)。上述路径将包含一个名为 iPhoneOS.sdk 的目录和一个针对此目录的别名(符号链接),该目录根据 SDK 版本(iPhoneOS10.0.sdk -> iPhoneOS.sdk)命名
  • 没有应用程序提供的方法(即其他 UI 可供性的偏好)来改变这个特性。
    • 虽然目录名称 (SDK) 的复数形式似乎是一个令人烦恼/嘲笑的选择,但您可以修改此应用程序包内目录的内容,以包含指向其他 Xcode 版本中包含的 SDK 的符号链接。
    • 这似乎只适用于前向,即在较旧的 Xcode 中使用较新的 SDK(例如 Xcode 7 中的 iOS 10 SDK)。这个方向一直满足我的历史需求。直到最近我才尝试倒退(使较新的 Xcode 使用较旧的 SDK,例如 Xcode 7 中的 iOS 8.4 SDK),我发现最近的 Xcode 安装(10.11.6 系统上的 8.0 和 7.3.1 版)忽略符号旧 SDK 的链接(即它们不会出现在目标的 Base SDK 弹出菜单中——Xcode 7.3.1 的屏幕截图,忽略了 iOS 8.4 SDK 符号链接)。
      • 更新(新详细信息):我仔细检查了我的家用机器(我曾用于其他多 SDK 实验),发现旧 SDK 确实出现在 Base SDK 弹出窗口中。神秘!这是一个 10.10.5 系统,运行 Xcode 7.2.1(随 iOS 9.2 SDK 一起提供),编辑​​不同的(非 iovation)Xcode 项目,iOS 8.2 SDK(来自 Xcode 6.2)将显示在弹出窗口中。显然,设置之间存在许多差异,我不知道哪些变量会导致行为差异。
        • 谜团已解决:最近的 Xcode 安装(上述版本 8.0 和 7.3.1)MinimumSDKVersion…/iPhoneOS.platform/Info.plist文件中包含一个密钥。这个键似乎被设置为 Xcode 附带的 SDK(即在应用程序包内),因此阻止 Xcode 识别旧的 SDK。我首先从 xcodebuild 命令行工具中了解了这个最小版本机制,该工具正在打印“ Skipped SDK <sdk-path>; its version (8.4) is below required minimum (10.0) for the iphoneos platform.
        • 编辑MinimumSDKVersionplist 键(例如使其成为 8.0)允许显示和选择旧的 SDK!
  • Apple 严格地将 SDK 版本绑定到 Xcode 版本这一事实一直困扰着我。通常,我更愿意在现有的 Xcode 安装中添加一个 SDK,而不是仅仅为了获得对新版本 iOS 的支持而更新整个 Xcode 环境。诚然,以锁步方式(应用程序、工具、设备和操作系统支持)带来一切似乎确实应该简化 Apple 的支持问题,而且,也许,他们认为这种联合进展也简化了 3rd 方开发人员的事情(没有选择)烦恼,只需更新应用程序)。