Skip to content

Commit

Permalink
Update setup.md for 5.10 release and add setup-snapshot.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Jun 13, 2024
1 parent bb1dd0d commit a17c6b3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Introduction](README.md)
- [Getting Started](getting-started/index.md)
- [Installation](getting-started/setup.md)
- [Development Snapshot](getting-started/setup-snapshot.md)
- [Hello, World](getting-started/hello-world.md)
- [Using Swift Package Manager](getting-started/swift-package.md)
- [Porting code from other platforms](getting-started/porting.md)
Expand Down
77 changes: 77 additions & 0 deletions src/getting-started/setup-snapshot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Installation - Development Snapshot

## WebAssembly SDK - Cross compile to WebAssembly

The upstream Open Source Swift toolchain does support WebAssembly as a target platform since **Swift 6.0**.
For those versions, you just need to install [Swift SDK for cross-compilation](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md).


## Instructions

1. **Find a Development Snapshot**

Visit the [SwiftWasm GitHub Releases page](https://github.com/swiftwasm/swift/releases).

2. **Match the Swift Toolchain Version**

Refer to the release note's table to find the corresponding upstream Swift toolchain version.
> For example, [`swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-12-a`](https://github.com/swiftwasm/swift/releases/tag/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-12-a) corresponds to `swift-DEVELOPMENT-SNAPSHOT-2024-06-11-a`
3. **Download the Swift Toolchain**

Download the appropriate Swift toolchain version from [swift.org/install](https://www.swift.org/install).

4. **Get the Swift SDK artifactbundle URL**

Find the URL ending with `.artifactbundle.zip` from the release page you found in step 1.

5. **Install the Swift SDK for WebAssembly**

Use the following command to install the Swift SDK:
```console
$ swift sdk install <URL-or-filename-of-swift-sdk-artifactbundle>
```
> For example, if you selected `swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-12-a`, you need to run the following command:
> ```console
> $ swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-12-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-12-a-wasm32-unknown-wasi.artifactbundle.zip
> ```
6. You can see the installed SDKs using the following command:
```console
$ swift sdk list
<Swift SDK id>
...
```
> Once you don't need the SDK, you can remove it using the following command:
> ```console
> $ swift sdk remove <Swift SDK id>
> ```
## How to use the Swift SDK
First, create a new Swift package using the following command:
```console
$ mkdir Example
$ cd Example
$ swift package init --type executable
```
Then, you can build the package using the Swift SDK:

```console
$ swift build --swift-sdk wasm32-unknown-wasi
# or
$ swift build --swift-sdk <Swift SDK id>
```

## FAQ

### What is the difference between the Swift Toolchain and the Swift SDK?

The Swift toolchain is a complete package that includes the Swift compiler, standard library, and other tools.

The Swift SDK includes a subset of the Swift toolchain that includes only the necessary components for cross-compilation and some supplementary resources.

### What is included in the Swift SDK for WebAssembly?

The Swift SDK for WebAssembly includes only the pre-built Swift standard libraries for WebAssembly. It does not include the Swift compiler or other tools that are part of the Swift toolchain.
30 changes: 13 additions & 17 deletions src/getting-started/setup.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# Installation
# 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.

## Latest Release

**SwiftWasm 5.9**

Tag: [swift-wasm-5.9.1-RELEASE](https://github.com/swiftwasm/swift/releases/tag/swift-wasm-5.9.1-RELEASE)
Tag: [swift-wasm-5.10.0-RELEASE](https://github.com/swiftwasm/swift/releases/tag/swift-wasm-5.10.0-RELEASE)

| Download | Docker Tag |
|:------------------:|:----------:|
| [macOS arm64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.1-RELEASE/swift-wasm-5.9.1-RELEASE-macos_arm64.pkg) | Unavailable |
| [macOS x86](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.1-RELEASE/swift-wasm-5.9.1-RELEASE-macos_x86_64.pkg) | Unavailable |
| [Ubuntu 18.04 x86_64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.1-RELEASE/swift-wasm-5.9.1-RELEASE-ubuntu18.04_x86_64.tar.gz) | [5.9-bionic, bionic](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [Ubuntu 20.04 x86_64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.1-RELEASE/swift-wasm-5.9.1-RELEASE-ubuntu20.04_x86_64.tar.gz) | [5.9-focal, focal](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [Ubuntu 20.04 aarch64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.1-RELEASE/swift-wasm-5.9.1-RELEASE-ubuntu20.04_aarch64.tar.gz) | [5.9-focal, focal](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [Ubuntu 22.04 x86_64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.1-RELEASE/swift-wasm-5.9.1-RELEASE-ubuntu22.04_x86_64.tar.gz) | [5.9, 5.9-jammy, jammy, latest](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [macOS arm64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-macos_arm64.pkg) | Unavailable |
| [macOS x86](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-macos_x86_64.pkg) | Unavailable |
| [Ubuntu 18.04 x86_64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-ubuntu18.04_x86_64.tar.gz) | [5.10-bionic, bionic](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [Ubuntu 20.04 x86_64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-ubuntu20.04_x86_64.tar.gz) | [5.10-focal, focal](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [Ubuntu 20.04 aarch64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-ubuntu20.04_aarch64.tar.gz) | [5.10-focal, focal](https://github.com/orgs/swiftwasm/packages/container/package/swift) |
| [Ubuntu 22.04 x86_64](https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.10.0-RELEASE/swift-wasm-5.10.0-RELEASE-ubuntu22.04_x86_64.tar.gz) | [5.10, 5.10-jammy, jammy, latest](https://github.com/orgs/swiftwasm/packages/container/package/swift) |


You can download the latest development snapshot from [the Releases page](https://github.com/swiftwasm/swift/releases)
You can find older releases from the [GitHub Releases page](https://github.com/swiftwasm/swift/releases?q=prerelease%3Afalse)

## Toolchain Installation

Expand All @@ -37,7 +33,7 @@ export PATH=/Library/Developer/Toolchains/<toolchain name>.xctoolchain/usr/bin:"
```bash
$ swift --version
# Or TOOLCHAINS=swiftwasm swift --version
SwiftWasm Swift version 5.9.1 (swiftlang-5.9.1)
SwiftWasm Swift version 5.10-dev
Target: x86_64-apple-darwin21.6.0
```

Expand All @@ -52,13 +48,13 @@ If you want to uninstall the toolchain, you can remove the toolchain directory f

SwiftWasm provides [Swift SDK](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md)s 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.9 or later. Then, you can install the Swift SDK using the following command while replacing `<your platform>`:
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>`:

```bash
$ swift experimental-sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9.2-RELEASE/swift-wasm-5.9.2-RELEASE-<your platform>.artifactbundle.zip
$ 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](https://github.com/swiftwasm/swift/releases/tag/swift-wasm-5.9.2-RELEASE).
You can find the latest Swift SDK release from [the GitHub Releases page](https://github.com/swiftwasm/swift/releases/tag/swift-wasm-5.10.0-RELEASE).

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

Expand Down
2 changes: 1 addition & 1 deletion src/getting-started/swift-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ swift build --triple wasm32-unknown-wasi
If [you installed Swift SDK instead of the whole toolchain](./setup.md#experimental-swift-sdk), you need to use the following command:

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

## 3. Run the produced binary
Expand Down

0 comments on commit a17c6b3

Please sign in to comment.