SDKROOT path for latest SDK

最后都变了- 提交于 2019-12-02 19:09:20

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

/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

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.

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.

With xcodebuild -version -sdk macosx10.7 Path you 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.

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

As stated in another stackoverflow question:

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

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

xcode-select --install
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!