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
You can download the latest development snapshot from [the Releases page](https://github.com/swiftwasm/swift/releases)
22
22
23
+
## Toolchain Installation
23
24
24
-
#Using Downloads
25
+
### macOS
25
26
26
-
## macOS
27
-
28
-
An Xcode toolchain (`.xctoolchain`) includes a copy of the compiler, linker, and other related tools needed to provide a cohesive development experience for working in a specific version of Swift.
29
-
30
-
31
-
### Requirements
32
-
33
-
- macOS 10.15 or later
34
-
35
-
36
-
### Installation
37
-
38
-
1.[Download the latest package release](https://book.swiftwasm.org/getting-started/setup.html#swiftwasm-57) according to your CPU architecture (arm64 for [Apple Silicon Macs](https://support.apple.com/en-us/HT211814), x86 for Intel Macs).
27
+
1.[Download the latest package release](#latest-release) according to your CPU architecture (arm64 for [Apple Silicon Macs](https://support.apple.com/en-us/HT211814), x86 for Intel Macs).
39
28
2. Run the package installer, which will install an Xcode toolchain into `/Library/Developer/Toolchains/`.
40
-
3. To use the Swift toolchain with command-line tools, use `xcrun --toolchain swiftwasm` or add the Swift toolchain to your path as follows:
29
+
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:
4. Run `swift --version`. If you installed the toolchain successfully, you can get the following message.
47
36
48
37
```bash
49
38
$ swift --version
39
+
# Or TOOLCHAINS=swiftwasm swift --version
50
40
SwiftWasm Swift version 5.9.1 (swiftlang-5.9.1)
51
41
Target: x86_64-apple-darwin21.6.0
52
42
```
53
43
54
-
> Warning: `xcrun` finds executable binary based on `--toolchain` option or `TOOLCHAINS` environment variable, but it also sets `SDKROOT` as host target SDK (e.g. `MacOSX.sdk`). So you need to specify `-sdk` option as `/Library/Developer/Toolchains/swift-wasm-5.9.1-RELEASE.xctoolchain/usr/share/wasi-sysroot` when launching `swiftc` from xcrun. `swift build` or other SwiftPM commands automatically find SDK path based on target triple, so they don't require to specify it.
55
-
56
-
57
44
## Linux
58
45
59
-
Packages for Linux are tar archives including a copy of the Swift compiler, linker, and related tools. You can install them anywhere as long as the extracted tools are in your PATH.
46
+
1.[Download the latest package release](#latest-release) according to your Ubuntu version and CPU architecture.
47
+
2. Follow the official Swift installation guide for Linux from [swift.org](https://www.swift.org/install/linux/#installation-via-tarball) while skipping GPG key verification, which is not provided for SwiftWasm releases.
60
48
61
-
### Requirements
49
+
<!--- TODO: Update the link and uncomment after releasing 5.9.2
50
+
## Experimental: Swift SDK
62
51
63
-
- Ubuntu 18.04 or 20.04 (64-bit)
64
-
65
-
### Installation
66
-
67
-
1. Install required dependencies:
52
+
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.
68
53
54
+
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:
69
55
70
56
```bash
71
-
# Ubuntu 18.04
72
-
apt-get install \
73
-
binutils \
74
-
git \
75
-
libc6-dev \
76
-
libcurl4 \
77
-
libedit2 \
78
-
libgcc-5-dev \
79
-
libpython2.7 \
80
-
libsqlite3-0 \
81
-
libstdc++-5-dev \
82
-
libxml2 \
83
-
pkg-config \
84
-
tzdata \
85
-
zlib1g-dev
86
-
# Ubuntu 20.04
87
-
apt-get install \
88
-
binutils \
89
-
git \
90
-
gnupg2 \
91
-
libc6-dev \
92
-
libcurl4 \
93
-
libedit2 \
94
-
libgcc-9-dev \
95
-
libpython2.7 \
96
-
libsqlite3-0 \
97
-
libstdc++-9-dev \
98
-
libxml2 \
99
-
libz3-dev \
100
-
pkg-config \
101
-
tzdata \
102
-
zlib1g-dev
57
+
$ swift experimental-sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.9-SNAPSHOT-2024-03-02-a/swift-wasm-5.9-SNAPSHOT-2024-03-02-a-macos_arm64.artifactbundle.zip
103
58
```
104
59
105
-
2. Download the latest binary release above.
106
-
107
-
The `swift-wasm-<VERSION>-<PLATFORM>.tar.gz` file is the toolchain itself.
108
-
109
-
3. Extract the archive with the following command:
60
+
After installing the Swift SDK, you can see the installed SDKs using the following command:
110
61
111
62
```bash
112
-
tar xzf swift-wasm-<VERSION>-<PLATFORM>.tar.gz
63
+
$ swift experimental-sdk list
64
+
<SDK name>
65
+
...
113
66
```
114
-
This creates a usr/ directory in the location of the archive.
115
67
68
+
You can use the installed SDKs to cross-compile Swift packages for WebAssembly using the following command:
116
69
117
-
4. Add the Swift toolchain to your path as follows:
118
-
119
-
```
120
-
export PATH=$(pwd)/usr/bin:"${PATH}"
70
+
```bash
71
+
$ swift build --experimental-swift-sdk <SDK name>
121
72
```
122
73
123
-
You can now execute the swiftc command to build Swift projects.
0 commit comments