Allow SPM to specify a toolchain dependency

i quite often find myself running into one of the following scenarios:

  1. i upgrade my toolchain, but forget to upgrade the toolchain tag for a dependency like swift-syntax. the package compiles without problems.

    at runtime it crashes, because it detects that the compiled swift-syntax bindings do not match the version of the toolchain they were linked against.

  2. i add an SPM sourcegen plugin to my project. i upgrade my toolchain, but forget to upgrade the toolchain tag for the SPM plugin. when i run the plugin, it formats my sources according to the wrong version of swift for my compiler.

  3. i add an SPM plugin to my library project. the downstream users of my library can no longer consume the library, because the plugin dependency is specified as a branch (as it must, for toolchain compatibility) and not a semantic version, even though the plugin dependency is not transitive.

at this point, i feel like SPM really needs a “toolchain” dependency kind, which is non-transitive and can accept a toolchain tag such as swift-DEVELOPMENT-SNAPSHOT-yyyy-mm-dd-h.

.package(url: "https://github.com/apple/swift-markdown", 
    swift: "swift-DEVELOPMENT-SNAPSHOT-2022-08-15-a")

this would be separate from // swift-tools-version: which is coarser and usually for me lags the actual toolchain by 2 or 3 minor swift versions.

what do you think?

2 Likes