You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The upstream Open Source Swift toolchain does support WebAssembly as a target platform since **Swift 6.0**.
6
+
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).
7
+
8
+
9
+
## Instructions
10
+
11
+
1.**Find a Development Snapshot**
12
+
13
+
Visit the [SwiftWasm GitHub Releases page](https://github.com/swiftwasm/swift/releases).
14
+
15
+
2.**Match the Swift Toolchain Version**
16
+
17
+
Refer to the release note's table to find the corresponding upstream Swift toolchain version.
18
+
> 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`
19
+
20
+
3.**Download the Swift Toolchain**
21
+
22
+
Download the appropriate Swift toolchain version from [swift.org/install](https://www.swift.org/install).
23
+
24
+
4.**Get the Swift SDK artifactbundle URL**
25
+
26
+
Find the URL ending with `.artifactbundle.zip` from the release page you found in step 1.
27
+
28
+
5.**Install the Swift SDK for WebAssembly**
29
+
30
+
Use the following command to install the Swift SDK:
31
+
```console
32
+
$ swift sdk install <URL-or-filename-of-swift-sdk-artifactbundle>
33
+
```
34
+
> For example, if you selected `swift-wasm-DEVELOPMENT-SNAPSHOT-2024-06-12-a`, you need to run the following command:
35
+
> ```console
36
+
> $ 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
37
+
> ```
38
+
6. You can see the installed SDKs using the following command:
39
+
```console
40
+
$ swift sdk list
41
+
<Swift SDK id>
42
+
...
43
+
```
44
+
> Once you don't need the SDK, you can remove it using the following command:
45
+
> ```console
46
+
> $ swift sdk remove <Swift SDK id>
47
+
> ```
48
+
49
+
## How to use the Swift SDK
50
+
51
+
First, create a new Swift package using the following command:
52
+
53
+
```console
54
+
$ mkdir Example
55
+
$ cd Example
56
+
$ swift package init --type executable
57
+
```
58
+
59
+
Then, you can build the package using the Swift SDK:
60
+
61
+
```console
62
+
$ swift build --swift-sdk wasm32-unknown-wasi
63
+
# or
64
+
$ swift build --swift-sdk <Swift SDK id>
65
+
```
66
+
67
+
## FAQ
68
+
69
+
### What is the difference between the Swift Toolchain and the Swift SDK?
70
+
71
+
The Swift toolchain is a complete package that includes the Swift compiler, standard library, and other tools.
72
+
73
+
The Swift SDK includes a subset of the Swift toolchain that includes only the necessary components for cross-compilation and some supplementary resources.
74
+
75
+
### What is included in the Swift SDK for WebAssembly?
76
+
77
+
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.
@@ -52,13 +48,13 @@ If you want to uninstall the toolchain, you can remove the toolchain directory f
52
48
53
49
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.
54
50
55
-
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>`:
51
+
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>`:
56
52
57
53
```bash
58
-
$ 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
54
+
$ 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
59
55
```
60
56
61
-
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).
57
+
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).
62
58
63
59
After installing the Swift SDK, you can see the installed SDKs using the following command:
0 commit comments