SwiftPackageIndex-Server icon indicating copy to clipboard operation
SwiftPackageIndex-Server copied to clipboard

Swift 5.9 build failure with versioned Package.swift

Open sbooth opened this issue 6 months ago • 5 comments

I have a package that I believe should build back to Swift 5.3 but SPI is showing a build failure with Swift 5.9. I recently added support for package traits (new in Swift 6.1) and as a result renamed the old package manifest to [email protected] to attempt to maintain backwards compatibility.

One of the build failures in question is here, summarized:

error: 'spi-builder-workspace': package 'spi-builder-workspace' is using Swift tools version 6.1.0 but the installed version is 5.9.0

The 5.10 and 6.0 builds work correctly- which leads me to believe the right manifest is being used for those builds- but I'm not sure if I'm using versioned manifests incorrectly (perhaps the new one should be [email protected]?) or if the problem is SPI-specific or lies elsewhere.

sbooth avatar Jun 13 '25 16:06 sbooth

Yeah, it's odd that this fails on 5.9. My best guess is that it's some weirdness around versioned package manifest resolution in SwiftPM.

FWIW, we're only days away from adding Swift 6.2 and dropping 5.9 - so this problem will go away on its own :)

finestructure avatar Jun 13 '25 16:06 finestructure

When Swift picks up those alternate package formats is sometimes confusing. The one you created will only activate for Swift 5.3 - if you want one to override Package.swift for 5.9 specifically, you'd need one that was the "[email protected].

Think of them as point fixes for single, specific older versions of the swift compiler. I didn't find the pattern intuitive, but once you know... it's a little easier to judge if you want to wrangle that or not.

heckj avatar Jun 13 '25 17:06 heckj

The weird thing is that only 5.9 is failing. I'd have expected all except 6.1 to fail.

finestructure avatar Jun 13 '25 17:06 finestructure

Me too

heckj avatar Jun 13 '25 17:06 heckj

Think of them as point fixes for single, specific older versions of the swift compiler.

I was under the impression (based on blog posts) that Swift's build system would pick the one that is closest to the current toolchain but I haven't seen any official documentation one way or the other. It's confusing to me why 5.9 fails but 5.10 doesn't. Time to download old Xcode versions and experiment I suppose.

sbooth avatar Jun 13 '25 19:06 sbooth