Understanding the swift --version output on macOS

i notice on macOS, the swift --version splash screen looks different than it does on linux.

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

what does the .13 component in swiftlang-5.10.0.13 refer to?

As a former Apple person, most likely an Apple-internal build number, roughly "the number of times we snapshotted the 5.10 branch for Xcode before release". Probably also includes submissions from main before the official branch date.

would it be sensible to map these numbers to publicly-known repo tags, such as swift-5.10-RELEASE? the use case is to select a version of the standard library to link against.

I think you can assume that any released Xcode's swiftc is corresponding to the final release tag no matter what the snapshot is, and that any beta Xcode's swiftc doesn't necessarily correspond to any tag yet. It's also the case that Apple makes downstream changes to Swift, so the build in question doesn't actually correspond to a public tag, but I guess they can't do so incompatibly without breaking downloadable toolchains.

4 Likes

To add to this: the standard library as shipped with Darwin does not correspond directly to any version in Open Source; as Jordan says, there are additional downstream changes that are folded in. In some areas this means that code will work or perform differently to the system version of the standard library. (The same is true of the compiler itself.)

I'm not sure what the official position is on using an OSS standard library with a non-OSS compiler. I don't think we'd intentionally break that, but do note that the compiler and library are presently developed in lock-step, and we test the OSS compiler with the OSS standard library, and the compilers shipped in the Xcode toolchains with the Darwin versions of the standard library. Certainly you're on safer ground if you avoid mixing and matching.

1 Like