Swift Tools Version best practices

When creating a new package, the default swift-tools-version is always the most recent version available. However, this prevents older toolchains from using the package.

Is it a good idea to deliberately set swift-tools-version as old as possible for the sake of compatibility? For instance, if my package runs in Swift 4.0, and I’m not using any SPM features that have been added in the interim, should I set the tools version accordingly? Or should I leave it at the latest version, currently 5.5?

I would think of this as a question of what you want to test and support. If you set the tools-version to 4.0, you should have a testing process which actually tests that the package works with 4.0 and significant versions in between, which can be a burden. You can't really rely on testing a 4.0 package with the latest tools to validate that it works with older ones.

On the other hand, it is of course better to support more tools-versions because you cover more users.

1 Like

Is there a downside to doing so, testing aside? Optimizations that cannot happen on older versions, etc.

Terms of Service

Privacy Policy

Cookie Policy