Availability of standard library types not restricted by swift-tools-version?

I have a package with swift-tools-version:5.3 but both Xcode 14.3 and the macos-latest and ubuntu-latest Github runners don't complain when a Sendable conformance was added to a type in the package.

To my understanding, Sendable was added in Swift 5.5, so shouldn't the compiler complain when a type added in a later version is added to a package with a lower tools version?

1 Like

The tools version warns older toolchains to ignore that version during resolution because the manifest contains things they will not understand.

In the source files the compiler only sees the #if checks that it passes, and cannot know what another compiler might see instead. If a toolchain were to object to the presence of new features, it would be impossible to support multiple toolchains at once. Even a Sendable conformance inside #if swift(>=5.5) would flag as though it were not available far enough back.

If you want to ensure your package actually supports its tool version, you must actually test it with that toolchain. For GitHub actions, the easiest way is to put a job on one of the docker images from the particular Swift release, which is done like so.