Support compiling project with Swift 5.5 #1049
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When using SwiftSyntax and linking to a specific version of lib_internalSwiftSyntaxParser, it does not matter which toolchain you use to compile the project.
In #1037, we just updated Package.swift to require Swift 5.6 or later (Xcode 13.3+), enforced by setting
swift-tools-version
to 5.6 - Doing this then caused SPM to update the Package.resolved format to v2 and also required some syntax changes in Package.swift, but that's about it since using SwiftSyntax 0.50600.1 and linking to the right version of lib_internalSwiftSyntaxParser is something separate.The downside locking into Swift 5.6+ is that you can no longer build the project using anything older than Xcode 13.3. While this is not common, since most users of Sorcery use the precompiled binary, there are still some users who want to be able to use tools such as Mint to compile from source but find themselves unable to (i.e if they user GitHub Actions, which don't currently support Xcode 13.3/macOS 12) - #1045
Initially I thought that if we wanted to support Xcode 13, 13.1 or 13.2 then we had to use SwiftSyntax 0.50500.0, and thus have essentially two different versions of Sourcery to test/maintain, I thought that this wouldn't be worth doing. But after testing, it seems like its simpler than that.
Changes
In this change, I update Package.swift to set
swift-tools-version
back to 5.5, revert some syntax changes and revert Package.resolved back to the v1 format (being careful to preserve the pins from before). This allows the following:We could continue to support Swift 5.5 like this until a point where we might want to use Swift 5.6 language specific features in the codebase.
I guess the one big thing to note here, since it is a bit meta and confusing, while you can compile the
sourcery
codebase with Swift 5.5, we still use SwiftSyntax 5.6 and therefore remain able to parse the AST of both Swift 5.5 and 5.6 source code.Note: Since we downgrade swift tools here, this might need you to clear out .swiftpm or .build directories on local machines. I don't anticipate that to be much of a problem though.