Reputation: 649
In a build script, I use /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
to find the most recent MacOSX SDK. MacOSX.sdk seems to contain the most recent version of the MacOSX.sdk while the MacOSX#.#.sdk is a symlink to MacOSX.sdk (I know it seems backwards).
Example ls -al
Oct 21 10:43 MacOSX.sdk
Nov 9 14:57 MacOSX11.0.sdk -> MacOSX.sdk
My question is, is this feature documented anywhere? I would like to have a guarantee that this will work going forward, and I would like to know how far back the feature existed.
Upvotes: 1
Views: 459
Reputation: 7922
Is Xcode's
SDKs/MacOSX.sdk
Symlink a Documented Feature
It's technically a MacOSX<version>.sdk
symlink which points to the new (undocumented) standard of simply MacOSX.sdk
.
It appears the symlink itself is a relatively new, backwards compatible feature for the old convention. This convention appears to be defacto-only and therefor NOT a documented feature. Historically -- in some instances -- the symlink was even bugged and left out by the installer.
@QuinceyMorris
from developer.apple.com forums summarizes this well:
"In the past, Xcode shipped with multiple SDK versions, and you could use any of the SDKs that came with the version of Xcode you were using. Currently, Xcode ships with only the latest SDK.
You no longer need multiple SDKs to target different versions of macOS. Instead, you write availability tests in your source code to choose different code paths based on the macOS version where your app is running."
For example:
MacOSX10.3.9.pkg
, there is no MacOSX.sdk
, but rather MacOSX10.3.9.sdk
.MacOSX10.6.sdk
, there is no MacOSX.sdk
, but rather MacOSX10.6.sdk
Most build systems will leverage a tool like xcrun
to locate this e.g:
xcrun --show-sdk-path
Which on newer OSs will generally list the unversioned path e.g:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
... or if multiples are installed, you can specify the target SDK:
xcrun --sdk macosx10.14 <command>
Note, since XCode install destination can vary (as well as be named XCode Beta.app
, using a helper tool to locate this directory is strongly advised.
However, using the newer MACOSX_DEPLOYMENT_TARGET
technique seems to be the new "standard", and will completely avoid the versioned SDK folder, assuming it works for your needs.
Upvotes: 1