Hello Everyone,
Swiftly is a command-line tool to help you to get started with the Swift toolchain that you need for your Swift development. It also helps you to switch easily between multiple versions of the Swift toolchain, including the latest and greatest snapshots, so that you can check that your code is ready for the next release.
We have started working with Swiftly and are proposing the following changes to move it towards being the default install experience for Swift:
macOS support
Swiftly currently only works with Linux. We would like to bring the experience to macOS too.
Command proxies
Currently, Swiftly can install multiple toolchains, but there's a single set of symbolic links that point to the toolchain that is in-use. The setting is global and you have to remember to use the correct toolchain for your project before you swift build
or swift test
your code. If you're working on multiple projects at the same time this can be error prone.
We plan on moving Swiftly to a proxy mechanism that allows you to specify the toolchain that you want to build, test, or compile like this:
swift build +latest # Installs the latest toolchain and uses that to build
swift test +5.10.1 # Uses the 5.10.1 toolchain to test (install if necessary)
clang +main-latest -o foo.o foo.c # Compile using the latest main snapshot toolchain
If you forget to specify the toolchain selector (with the '+') then the proxies will try to use the global default, much like how the symlinks work today. But, if you want to set a local default for a project just use
it.
cd my/project
swiftly use 5.10.0 # Sets the default for the project to 5.10.0
The setting is stored in a .swift-version
file in the project and you can share this with the rest of your team, updating it as you decide to adopt new toolchains.
Shell script migration to pure Swift
Currently, there is a shell script that performs a number of tasks, such as installing Swiftly, and installing system packages needed by the toolchains. You normally encounter this script when you follow the instructions using curl. We would like to move this logic into Swiftly itself, written in Swift.
Swiftly itself can run through its own installation process, such as detecting your Linux distribution, processor architecture, determining your shell (sh, bash, or fish), and updating your profile (PATH, environment variables). The same code runs independently of the delivery process, whether direct download, or a system package installer. Plus, it doesn't depend on having curl installed.
Since Swiftly is a user-level toolchain management tool we feel that it is out of scope for it to try to directly update your entire system, installing missing packages, and requiring your sudo password to do that. Instead, it will query for missing packages, if any, and give you the commands that can set up the necessary prerequisites. For most developers your system will already have the necessary packages and so things will just work. There's no need to prompt for a password to perform these checks.
Remove GitHub API dependencies
Swiftly uses the GitHub REST API at the moment to query for toolchain releases and snapshots. Also, this is how it detects self updates and downloads its latest version. However, there are limits to this API. For example, there are actual rate limits that can impact some users. It doesn't have the necessary metadata to determine if a particular release or snapshot is supported on your Linux distribution, or processor architecture leading to failed downloads.
Swiftly can switch to use swift.org itself to query for the necessary metadata. There's a much higher rate limit, which allows us to finally unveil the hidden list-available
subcommand that allows you to perform queries for available toolchains that match your environment.
swiftly list-available 5.10 # Show me the 5.10.x releases for my system
swiftly list-available main-latest # Show me the latest snapshot releases for my system
Swiftly will also be published on swift.org. That's right, the same place where you get your toolchains is the place where you can also get your toolchain manager, Swiftly. This allows us to remove the dependency on the GitHub API completely, replacing it with queries to swift.org itself.
I hope that these new enhancements will help you with your Swift development and also make Swift even more accessible to newcomers. What do you think of them?
Cheers,
Chris