Skip to content

Instantly share code, notes, and snippets.

@kkebo
Last active November 22, 2024 05:55
Show Gist options
  • Save kkebo/5471965f1ed4c63bb486f5ecdc6b3ee5 to your computer and use it in GitHub Desktop.
Save kkebo/5471965f1ed4c63bb486f5ecdc6b3ee5 to your computer and use it in GitHub Desktop.
swiftly on macOS
{
"installedToolchains" : [],
"platform" : {
"namePretty" : "macOS",
"architecture" : null,
"name" : "xcode",
"nameFull" : "osx"
}
}
set -x SWIFTLY_HOME_DIR "$HOME/Library/Application Support/swiftly"
set -x SWIFTLY_BIN_DIR "$SWIFTLY_HOME_DIR/bin"
if not contains "$SWIFTLY_BIN_DIR" $PATH
set -x PATH "$SWIFTLY_BIN_DIR" $PATH
end
export SWIFTLY_HOME_DIR="$HOME/Library/Application Support/swiftly"
export SWIFTLY_BIN_DIR="$SWIFTLY_HOME_DIR/bin"
if [[ ":$PATH:" != *":$SWIFTLY_BIN_DIR:"* ]]; then
export PATH="$SWIFTLY_BIN_DIR:$PATH"
fi
@kkebo
Copy link
Author

kkebo commented Nov 9, 2024

How to install swiftly on macOS (until its macOS support is released)

Notice

When swiftly’s macOS support is officially released, please follow https://swiftlang.github.io/swiftly instead of this page.

Prerequisites

  • Swift 6 (by installing Xcode 16 or manually installing the toolchain from https://swift.org))
    • Swift 5.x might be ok, but I haven't tested it.
  • macOS 15
    • macOS 14 and older might be ok, but I haven't tested them.

1. Build and install swiftly itself

git clone https://github.com/swiftlang/swiftly
cd swiftly
swift build -c release

mkdir -p "$HOME/Library/Application Support/swiftly/bin"
cp .build/release/swiftly "$HOME/Library/Application Support/swiftly/bin/"

2. Create config.json

Create ~/Library/Application Support/swiftly/config.json. (See above for its content)

3. Create env.fish

If you're using fish, create ~/Library/Application Support/swiftly/env.fish. (See above for its content)

If you're not using the other shells (e.g. ash, bash, zsh), create ~/Library/Application Support/swiftly/env.sh. (See above for its content)

4. Configure your shell

If you're using fish, create ~/.config/fish/conf.d/swiftly.fish with the following content:

source "$HOME/Library/Application Support/swiftly/env.fish"

If you're not using fish, add the following line to your ~/.profile, ~/.bash_profile:

source "$HOME/Library/Application Support/swiftly/env.fish"

5. Restart your shell

That's it!

$ swiftly list
Installed release toolchains
----------------------------

Installed snapshot toolchains
-----------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment