Installation - Latest Release (SwiftWasm 5.10)

To install Swift for WebAssembly toolchain, download one of the packages below and follow the instructions for your operating system.

Tag: swift-wasm-5.10.0-RELEASE

DownloadDocker Tag
macOS arm64Unavailable
macOS x86Unavailable
Ubuntu 18.04 x86_645.10-bionic, bionic
Ubuntu 20.04 x86_645.10-focal, focal
Ubuntu 20.04 aarch645.10-focal, focal
Ubuntu 22.04 x86_645.10, 5.10-jammy, jammy, latest

You can find older releases from the GitHub Releases page

Toolchain Installation

macOS

  1. Download the latest package release according to your CPU architecture (arm64 for Apple Silicon Macs, x86 for Intel Macs).
  2. Run the package installer, which will install an Xcode toolchain into /Library/Developer/Toolchains/.
  3. To use the Swift toolchain with command-line tools, use env TOOLCHAINS=swiftwasm swift or add the Swift toolchain to your path as follows:
export PATH=/Library/Developer/Toolchains/<toolchain name>.xctoolchain/usr/bin:"${PATH}"
  1. Run swift --version. If you installed the toolchain successfully, you can get the following message.
$ swift --version
# Or TOOLCHAINS=swiftwasm swift --version
SwiftWasm Swift version 5.10-dev
Target: x86_64-apple-darwin21.6.0

If you want to uninstall the toolchain, you can remove the toolchain directory from /Library/Developer/Toolchains/ and make sure to remove the toolchain from your PATH.

Linux

  1. Download the latest package release according to your Ubuntu version and CPU architecture.
  2. Follow the official Swift installation guide for Linux from swift.org while skipping GPG key verification, which is not provided for SwiftWasm releases.

Experimental: Swift SDK

SwiftWasm provides Swift SDKs for WebAssembly. You can use the Swift SDK to cross-compile Swift packages for WebAssembly without installing the whole toolchain.

To use the Swift SDK, you need to install the official Swift toolchain 5.10 or later. Then, you can install the Swift SDK using the following command while replacing <your platform>:

$ swift experimental-sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-<your platform>.artifactbundle.zip

You can find the latest Swift SDK release from the GitHub Releases page.

After installing the Swift SDK, you can see the installed SDKs using the following command:

$ swift experimental-sdk list
<SDK name>
...

You can use the installed SDKs to cross-compile Swift packages for WebAssembly using the following command:

$ swift build --experimental-swift-sdk <SDK name>

Docker

SwiftWasm offical Docker images are hosted on GitHub Container Registry.

SwiftWasm Dockerfiles are located on swiftwasm-docker repository.

Supported Platforms

  • Ubuntu 18.04 (x86_64)
  • Ubuntu 20.04 (x86_64, aarch64)
  • Ubuntu 22.04 (x86_64)

Using Docker Images

  1. Pull the Docker image from GitHub Container Registry:
docker pull ghcr.io/swiftwasm/swift:latest
  1. Create a container using tag latest and attach it to the container:
docker run --rm -it ghcr.io/swiftwasm/swift:latest /bin/bash