xcode 最新SDK的SDKROOT路径

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

SDKROOT path for latest SDK

xcodemacosxcode4.5ld

提问by PnotNP

I am using Xcode to build an old code and specify SDKROOT=/Developer/SDKs/MacOSX"${HOST_VERSION}".sdk/

我正在使用 Xcode 构建旧代码并指定 SDKROOT=/Developer/SDKs/MacOSX"${HOST_VERSION}".sdk/

I want to specify SDKROOT for latest SDK that comes pre-installed (?) on the system. e.g. I am on 10.8already and I want to specify SDKROOTwith -syslibroot, but there is no such SDK in /Developer/SDKs/. Should i just ignore syslibroot altogether if SDK_VERSION == HOST_VERSION?

我想为系统上预装 (?) 的最新 SDK 指定 SDKROOT。例如,我已经打开10.8了,我想SDKROOT用 -syslibroot指定,但是/Developer/SDKs/. 如果我应该完全忽略 syslibrootSDK_VERSION == HOST_VERSION吗?

回答by Martin R

Newer Xcode versions have the SDKs inside the Xcode.app bundle, e.g.

较新的 Xcode 版本在 Xcode.app 包中包含 SDK,例如

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk

You get the list of installed SDKs together with their path by running

您可以通过运行获取已安装 SDK 的列表及其路径

xcodebuild -sdk -version

from the command line.

从命令行。

If you have installed the "Command Line Tools" (Xcode Preferences -> Downloads -> Components) then compiling without "-syslibroot" should be equivalent to compiling against the latest SDK.

如果您已经安装了“命令行工具”(Xcode 首选项 -> 下载 -> 组件),那么在没有“-syslibroot”的情况下进行编译应该等同于针对最新的 SDK 进行编译。

See the help to the "Command Line Tools" package:

请参阅“命令行工具”包的帮助:

Downloading this package will install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.

下载此包会将核心命令行工具和系统头文件的副本安装到系统文件夹中,包括 LLVM 编译器、链接器和构建工具。

回答by Sven

With xcodebuild -version -sdk macosx10.7 Pathyou can get the Path to the OS X 10.7 SDK. You may replace 10.7 by ${SDK_VERSION}or ${HOST_VERSION}depending on your needs. I know of no command to obtain the version of OS X, which could be used to obtain the Path to the SDK matching the version of OS X currently running.

有了xcodebuild -version -sdk macosx10.7 Path你可以得到的路径OS X 10.7 SDK。可以更换10.7通过${SDK_VERSION}${HOST_VERSION}根据您的需要。我知道没有获取 OS X 版本的命令,该命令可用于获取与当前运行的 OS X 版本匹配的 SDK 路径。

Note: for xcodebuildto work, the user must have configured xcode-selectproperly, for example xcode-select -switch /Application/Xcode.app.

注意:为了xcodebuild工作,用户必须xcode-select正确配置,例如xcode-select -switch /Application/Xcode.app

回答by Sriram Murali

As stated in another stackoverflow question:

如另一个stackoverflow问题所述

xcrun --sdk macosx --show-sdk-path

回答by Fayaj

CommandLineTools was outdated, reinstalling Command Line Tools fixed the issue:

CommandLineTools 已过时,重新安装 Command Line Tools 修复了该问题:

xcode-select --install