My Swift Package specifies macOS 10.11 & Swift 5.6.1, but
Xcode 14.2 doesnât give me any warnings or errors about 10.11
being less than 10.13.
Letâs start with a basic test case. That chart lists the minimum deployment target for Xcode 16.0 as macOS 10.13. Using Xcode 16.0 I created a test project from the macOS > Command Line Tool template. I set the deployment target to 10.13 and the program compiled without problems. I then lowered it to 10.12, and the build started raising this warning:
The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.12, but the range of supported deployment target versions is 10.13 to 15.0.99.
I then repeated that process for a new package, created from the macOS Command-Line Tool template. There were a couple of things to note. The first is that, in the absence of any platform constraints, Xcode applies its default constraint. That is, out of the box the Command-Line Tool template builds for macOS 10.13. Consider this:
% vtool -show-build Test75120B
Test75120B (architecture x86_64):
Load command 9
cmd LC_VERSION_MIN_MACOSX
cmdsize 16
version 10.13
sdk 15.0
Test75120B (architecture arm64):
Load command 10
cmd LC_BUILD_VERSION
cmdsize 32
platform MACOS
minos 11.0
sdk 15.0
âŚ
Note how the Intel architecture targets 10.13 and the Apple silicon architecture targets 11.0, the initial macOS release for Apple silicon [1].
If I add a platform constraint for 10.12, I get this warning:
platforms: [.macOS(.v10_12)],
// ^ 'v10_12' is deprecated: macOS 10.13 is the oldest supported version
I havenât tested this on older versions of Xcode; itâs possible that those are less fastidious. Regardless, the rules here are clear: Xcode has a minimum deployment target for each platform, and targeting releases earlier than that is not supported.
Moreover, not following these rules can lead to weird problems, like the ones discussed in this thread.
So, could using Swift 5.6 on Xcode 14.2 allow me to deploy back to 10.9?
No. The Swift language version is not the deciding factor here. The entire toolchain is built with a minimum deployment target. IME the most critical components in this calculus are the SDK and linker.
Is the swift command-line executable considered part of
Xcode, specifically for the the versions of macOS supported as
deployment targets?
Yes.
And not just the Swift compiler. Each version of Xcode includes a toolchain, comprising the tools, SDK, and so on. That toolchain has the same deployment constraints as the Xcode in which itâs contained.
Likewise for the Command Line Tools package, where each package has the same deployment constraints as it âparentâ Xcode.
Share and Enjoy
Quinn âThe Eskimo!â @ DTS @ Apple
[1] Annoyingly, macOS does not currently enforce the constraints expressed in LC_VERSION_MIN_MACOSX and LC_BUILD_VERSION. That is, macOS 10.12 wonât fail early if you run this tool. It might work or it might not, depending on a variety of factors. (When things fail, they typically fail because of a dynamic linking error.)
IMO this is a bug. macOS should use this build commands to fail early. However, changing this is a compatibility challenge.