如何将 Xcode 指向旧 SDK,以便将其用作“基础 SDK”?

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

How to point Xcode to an old SDK so it can be used as a "Base SDK"?

xcodemacossdkxcode4xcode5

提问by Todd Ditchendorf

My Mac's Setup:

我的 Mac 设置:

Volume A:
OS X 10.8
Xcode 4.5 or later - 10.6 SDK IS NOTavailable as Base SDK

卷 A
OS X 10.8
Xcode 4.5 或更高版本 - 10.6 SDK不能作为基础 SDK

Volume B:
OS X 10.7
Xcode 4.3.3 - 10.6 SDK ISavailable as Base SDK

卷B
OS X 10.7
的Xcode 4.3.3 - 10.6 SDK IS可作为基地SDK

Volume C:
OS X 10.6
Xcode 4.2 - 10.6 SDK ISavailable as Base SDK

卷C
OS X 10.6
的Xcode 4.2 - 10.6 SDK IS可作为基地SDK



On Volume A, I have installed Xcode 4.5, which does not include the 10.6 SDK as an available "Base SDK" in my Build Targets' Build Settings.

在卷 A 上,我安装了 Xcode 4.5,它不包括 10.6 SDK 作为我构建目标的构建设置中可用的“基础 SDK”。

I have a separate 10.6 volume and 10.7 volume on this hard drive - both of which have Xcode installed, and both of which allow me to select the 10.6 SDK as a Base SDK in my Xcode Build Targets' Build Settings.

我在这个硬盘驱动器上有一个单独的 10.6 卷和 10.7 卷 - 两者都安装了 Xcode,并且两者都允许我在我的 Xcode Build Targets 的 Build Settings 中选择 10.6 SDK 作为 Base SDK。

I know that I have the 10.6 SDK installed on Volume C (at /Developer/SDKsfrom an older Xcode installation).

我知道我在 Volume C 上安装了 10.6 SDK(/Developer/SDKs来自较旧的 Xcode 安装)。

How can I point Xcode on Volume A to the 10.6 SDK which lives on Volume C?

如何将卷 A 上的 Xcode 指向位于卷 C 上的 10.6 SDK?

回答by Rob Napier

You'll need to add a symlink to the old SDK (this is generally easier than copying).

您需要向旧 SDK 添加一个符号链接(这通常比复制更容易)。

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
ln -s /path/to/old/SDK .

This works fine back to 10.5. Beyond that things get a little more complicated...

这可以很好地恢复到 10.5。除此之外,事情变得有点复杂......

While there's no promise in future versions of Xcode that this will be supported, I've chatted with the Xcode team about it and they don't seem keen on changing it anytime soon.

虽然在 Xcode 的未来版本中没有承诺会支持这点,但我已经与 Xcode 团队讨论过这个问题,他们似乎并不热衷于很快改变它。

Personally I often keep /path/to/old/SDK in a top-level directory called /SDKs. That way every time I upgrade it's easy to fix everything up.

我个人经常将 /path/to/old/SDK 保存在名为 /SDKs 的顶级目录中。这样每次我升级时都可以轻松修复所有内容。

EDIT: I have a fix-xcodescript that simplifies re-applying this fix every time Xcode upgrades.

编辑:我有一个fix-xcode脚本,可以简化每次 Xcode 升级时重新应用此修复程序的过程。



UPDATE: In modern versions of Xcode (7.3+) to use older SDKs edit MinimumSDKVersionhere:

更新:在现代版本的 Xcode (7.3+) 中使用旧版 SDKMinimumSDKVersion在此处编辑:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist

回答by danielpunkass

Wrong approach. You don't "point" Xcode at an SDK. Instead you will have better luck copying the SDK into the appropriate "SDKs" folder for the Xcode installation. In modern Xcode installations this is usually:

错误的做法。您不会将 Xcode“指向”SDK。相反,您将有更好的运气将 SDK 复制到 Xcode 安装的相应“SDKs”文件夹中。在现代 Xcode 安装中,这通常是:

Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

Copy the SDK in there, quit and restart Xcode and see what you find.

在那里复制 SDK,退出并重新启动 Xcode,看看你找到了什么。

(reading the other answer here I think that symbolic linking might be an option if you are dead-set on keeping the original SDK elsewhere)

(在这里阅读另一个答案,我认为如果您对将原始 SDK 保留在其他地方一无所知,则符号链接可能是一种选择)

回答by Byron

Why not just symbolic link the SDK's? "ln -s"? If that doesn't work there's going to be some plist hacking required.

为什么不只是符号链接 SDK 的?“ln -s”?如果这不起作用,则需要进行一些 plist hacking。

回答by Guesto

Solved by browsing to older version Xcode.App/Developer/platforms and copy the iOS 6.1 SDK into same folder of XCode 5.

通过浏览旧版本 Xcode.App/Developer/platforms 并将 iOS 6.1 SDK 复制到 XCode 5 的同一文件夹中解决。