Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swiftly README for the 1.0.0 release #236

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 45 additions & 237 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,274 +1,82 @@
# swiftly

swiftly is a CLI tool for installing, managing, and switching between [Swift](https://www.swift.org/) toolchains, written in Swift. swiftly itself is designed to be extremely easy to install and get running, and its command interface is intended to be flexible while also being simple to use. The overall experience is inspired by and meant to feel reminiscent of the Rust toolchain manager [rustup](https://rustup.rs/).
swiftly is a CLI tool for installing, managing, and switching between [Swift](https://www.swift.org/) toolchains, written in Swift. swiftly itself is designed to be extremely easy to install and get running, and its command interface is intended to be flexible while also being simple to use. You can use it with Linux and macOS.

Ongoing maintenance and stewardship of this project is led by the [SSWG](https://www.swift.org/sswg/).
### Installation and Basic Usage

### Installation
⚠️ Installation has changed from the 0.3.0 release. See [Upgrade from previous](#upgrade-from-previous) below for notes on upgrading from older releases.

Install swiftly using a script (hosted from this repository) using the command:
Install swiftly by going to the [Swift Install Page](https://swift.org/install) of swift.org and following the instructions there.

```
curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash
```

In the future, download the swiftly package from [swift.org](https://swift.org/download) and it can install itself with init:
Once swiftly is installed it will automatically install the latest released toolchain. You can use the familiar toolchain commands right away:

```
swiftly init
```

### Basic usage

```
$ swiftly install latest

Fetching the latest stable Swift release...
Installing Swift 5.8.1
Downloaded 488.5 MiB of 488.5 MiB
Extracting toolchain...
Swift 5.8.1 installed successfully!

$ swift --version

Swift version 5.8.1 (swift-5.8.1-RELEASE)
swift --version
--
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: x86_64-unknown-linux-gnu
```

## Features

- Installing multiple toolchains, including both stable releases and snapshots
- Switching which installed toolchain is active (i.e. which one is discovered via `$PATH`)
- Updating installed toolchains to the latest available versions of those toolchains
- Uninstalling installed toolchains
- Listing the toolchains that are available to install (not yet implemented)

## Platform support

- Linux-based platforms listed on https://swift.org/download

Right now, swiftly is in early stages of development and is supported on Linux and macOS. For more detailed information about swiftly's intended features and implementation, check out the [design document](DESIGN.md).

## Command interface overview

### Installing a toolchain

#### Install the latest version of Swift

```
$ swiftly install latest
```

#### Installing a specific release version of Swift

A specific version of Swift can be provided to the `install` command.

```
$ swiftly install 5.6.1
```

If a patch version isn't specified, swiftly will look up and install the latest patch version that matches the minor version provided:

```
$ swiftly install 5.6
```

#### Installing main development snapshots (trunk)

```
$ swiftly install main-snapshot-2022-01-28
```

If the date isn't specified, swiftly will look up and install the latest available snapshot:

```
$ swiftly install main-snapshot
```

#### Installing Swift version development snapshots

```
$ swiftly install 5.7-snapshot-2022-08-30
```

If the date isn't specified, swiftly will look up and install the latest snapshot associated with the provided development branch:

```
$ swiftly install 5.7-snapshot
```

### Uninstalling a toolchain

#### Uninstall a release toolchain

```
$ swiftly uninstall 5.6.3
```

To uninstall all toolchains associated with a given minor release, leave off the patch version:

```
$ swiftly uninstall 5.6
```

#### Uninstall a snapshot toolchain

```
$ swiftly uninstall main-snapshot-2022-08-30
$ swiftly uninstall 5.7-snapshot-2022-08-30
```

To uninstall all snapshots associated with a given branch (either main or a release branch), omit the date:

```
$ swiftly uninstall main-snapshot
$ swiftly uninstall 5.7-snapshot
```

### Listing installed toolchains

The `list` command prints all the toolchains installed by swiftly:

```
$ swiftly list
```

### Selecting a toolchain for use

“Using” a toolchain sets it as the active toolchain, meaning it will be the one found via $PATH and invoked via `swift` commands executed in the shell. The toolchain must be installed before you can use it.

You can provide the same version selectors as you used with `swiftly install` to use a toolchain, including exact releacs versions "major.minor.patch", and snapshots.

```
$ swiftly use latest
$ swiftly use 5.3.1
$ swiftly use 5.3
$ swiftly use 5.3-snapshot
$ swiftly use 5.3-snapshot-2022-08-16
$ swiftly use main-snapshot
$ swiftly use main-snapshot-2024-06-18
```

After you use a toolchain your commands at the shell will run with that toolchain:

```
$ swiftly use x.y.z
$ swift build # Build my package with toolchain version x.y.z
$ clang -c foo.c -o foo.o # Compile this C file using the clang compiler in toolchain version x.y.z
$ lldb # Open the debugger from toolchain version x.y.z
```

If you want to run just one command with a particular toolchain without having to switch back to the one you used previously you can use the `swiftly run` command with the version. This command builds your current package with the latest snapshot toolchain of the current release:

```
$ swiftly run swift build +main-snapshot
```

The parameter with the "+" indicates that this is the version selector of the toolchain to use and supports the full range of selectors shown above and with the `swiftly install` command. The toolchain must be installed to run a command with that toolchain.

### Updating a toolchain

Update replaces a given toolchain with a later version of that toolchain. For a stable release, this means updating to a later patch, minor, or major version. For snapshots, this means updating to the most recently available snapshot.

If no version is provided, update will update the currently selected toolchain to its latest patch release if a release toolchain or the latest available snapshot if a snapshot. The newly installed version will be selected.

```
$ swiftly update
```

To update the latest installed release version to the latest available release version, the “latest” version can be provided. Note that this may update the toolchain to the next minor or even major version.

```
swiftly update latest
```

If only a major version is specified, the latest installed toolchain with that major version will be updated to the latest available release of that major version:

```
swiftly update 5
```

If the major and minor version are specified, the latest installed toolchain associated with that major/minor version will be updated to the latest available patch release for that major/minor version.

```
swiftly update 5.3
```

You can also specify a full version to update that toolchain to the latest patch available for that major/minor version:

```
swiftly update 5.3.1
```

Similarly, to update the latest snapshot associated with a specific version, the “a.b-snapshot” version can be supplied:

```
swiftly update 5.3-snapshot
lldb
--
(lldb): _
```

You can also update the latest installed main snapshot to the latest available one by just providing `main-snapshot`:
Install another toolchain, such as the latest nightly snapshot of the main branch. Use it so that when you run a toolchain command it uses that one.

```
swiftly update main-snapshot
swiftly install main-snapshot
swiftly use main-snapshot
swift --version
--
Apple Swift version 6.2-dev (LLVM 059105ceb0cb60e, Swift 714c862d3791544)
Target: arm64-apple-macosx15.0
Build config: +assertions
```

A specific snapshot toolchain can be updated to the newest available snapshot for that branch by including the date:
For more detailed usage guides there is [documentation](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs).

```
swiftly update 5.9-snapshot-2023-09-20
```

### Listing toolchains available to install

The `list-available` command can be used to list the latest toolchains that Apple has made available to install.

Note that this command isn't implemented yet, but it will be included in a future release.

```
swiftly list-available
```
## Features

A selector can optionally be provided to narrow down the results:
- [Installing multiple toolchains](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/install-toolchains), including both stable releases and snapshots
- [Switching which installed toolchain is active](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/use-toolchains) (i.e. which one is discovered via `$PATH`)
- [Updating installed toolchains](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/update-toolchain) to the latest available versions of those toolchains
- [Uninstalling installed toolchains](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/uninstall-toolchains)
- Listing the toolchains that are available to install with the [list-available](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/swiftly-cli-reference#list-available) subcommand
- Sharing the preferred toolchain as a project setting with a [.swift-version](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/use-toolchains#Sharing-recommended-toolchain-versions) file
- Running a single command on a particular toolchain with the [run](https://swiftpackageindex.com/swiftlang/swiftly/main/documentation/swiftlydocs/swiftly-cli-reference#run) subcommand

```
$ swiftly list-available 5.6
$ swiftly list-available main-snapshot
$ swiftly list-available 5.7-snapshot
```
## Platform support

### Updating swiftly
swiftly is supported on Linux and macOS. For more detailed information about swiftly's intended features and implementation, check out the [design document](DESIGN.md).

This command checks to see if there are new versions of `swiftly` itself and upgrades to them if so.
## Updating swiftly

Note that this command isn't implemented yet, but it will be included in a future release.
This command checks to see if there are new versions of swiftly itself and upgrades to them if possible.

`swiftly self-update`

### Specifying a snapshot toolchain
## Contributing

The canonical name for a snapshot toolchain in swiftly's command interface is the following:
Welcome to the Swift community!

```
<branch>-snapshot-YYYY-MM-DD
```
Contributions to Swiftly are welcomed and encouraged! Please see the [Contributing to Swift guide](swift.org/contributing) and check out the [structure of the community](https://www.swift.org/community/#community-structure).

However, swiftly also accepts the snapshot toolchain filenames from the downloads provided by swift.org. For example:
To be a truly great community, Swift needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.

```
swift-DEVELOPMENT-SNAPSHOT-2022-09-10-a
swift-5.7-DEVELOPMENT-SNAPSHOT-2022-08-30-a
```
To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the [Code of Conduct](https://www.swift.org/code-of-conduct/).

The canonical name format was chosen to reduce the keystrokes needed to refer to a snapshot toolchain, but the longer form is also useful when copy/pasting a toolchain name provided from somewhere else.
## Upgrade from previous

## Contributing
Welcome to the Swift community!
Swiftly prior to verion 1.0.0 had a different installation and delivery mechanism. Upgrading to the newest version of swiftly involves two steps:

Contributions to Swiftly are welcomed and encouraged! Please see the [Contributing to Swift guide](swift.org/contributing) and check out the [structure of the community](https://www.swift.org/community/#community-structure).
1. Uninstall older swiftly
2. Install the newest swiftly using the instructions above

To be a truly great community, Swift needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.
To uninstall the old swiftly, first locate the swiftly home directory, which is often in `~/.local/share/swiftly` and remove it. Then check your shell profile files (`~/.profile`, `~/.zprofile`, `~/.bash_profile`, or `~/.config/fish/conf.d`) and remove any entries that attempt to source the `env.sh` or `env.fish` file in the swiftly home directory. Finally, remove the symbolic links that swiftly placed in your `~/.local/bin` to toolchain binaries (e.g. swift, clang, lldb, etc.). These will likely be symbolic links to toolchain directories in the swiftly home directory. Remove them so that there aren't any orphaned path entries.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the symbolic links point to the toolchain binaries still? They proxy into swifty itself now right?


To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the [Code of Conduct](https://www.swift.org/code-of-conduct/).
Restart your shell and/or terminal to get a fresh environment. You should be ready to installing the new swiftly.

## FAQ

Expand All @@ -280,13 +88,13 @@ Swift.org currently provides experimental [`.rpm` and `.deb`](https://forums.swi

swiftenv is an existing Swift version manager which already has much of the functionality that swiftly will eventually have. It's an awesome tool, and if it's part of your workflow then we encourage you to keep using it! That said, swiftly is/will be different a few ways:

- swiftly is being built as a community driven effort led by the Swift server workgroup, and through this collaboration, swiftly will eventually become an official installation tool for Swift toolchains. As first step towards that, swiftly will help inform the creation of API endpoints maintained by the Swift project that it will use to retrieve information about what toolchains are available to install and to verify their expected signatures. swiftenv currently uses a third party API layer for this. Using an official API reduces the avenues for security vulnerabilities and also reduces the risk of downtime affecting Swift installations.
- swiftly is being built as a community driven effort, and through this collaboration, swiftly is an official installation tool for Swift toolchains. swiftly has helped to inform the creation of API endpoints maintained by the Swift project that it uses to retrieve information about what toolchains are available to install and to verify their expected signatures. swiftenv currently uses a third party API layer for this. Using an official API reduces the avenues for security vulnerabilities and also reduces the risk of downtime affecting Swift installations.

- swiftly will be written in Swift, which we think is important for maintainability and encouraging community contributions.

- swiftly has first-class support for installing and managing snapshot toolchains.

- swiftly has built in support for updating toolchains.

- swiftly is optimized for ease of installation--it can be done with a bash one-liner similar to Homebrew and rustup. In addition, swiftly won't require any system dependencies to be installed on the user's system. While swiftenv is also relatively easy to install, it does involve cloning a git repository or using Homebrew, and it requires a few system dependencies (e.g. bash, curl, tar).
- swiftly is optimized for ease of installation. In addition, swiftly doesn't require any system dependencies to be installed on the user's system. While swiftenv is also relatively easy to install, it does involve cloning a git repository or using Homebrew, and it requires a few system dependencies (e.g. bash, curl, tar).