Skip to content

Commit b5d7d4e

Browse files
Add more guidance for the Swift SDK installation
1 parent 2d6a174 commit b5d7d4e

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

src/getting-started/setup.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,32 @@ Before installing the Swift SDK, you need to ensure the following:
88
- You cannot use toolchains bundled with Xcode to use the Swift SDK.
99
- If you are using macOS, please follow the [official guide](https://www.swift.org/install/macos/package_installer/) to install the toolchain.
1010

11+
Please ensure you have installed the Swift 6.0.3 Open Source toolchain.
12+
13+
```sh
14+
swift --version
15+
```
16+
17+
| Toolchain | Output |
18+
|-----------|--------|
19+
| ❌ Xcode | `Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)` |
20+
| ✅ Open Source (macOS) | `Apple Swift version 6.0.3 (swift-6.0.3-RELEASE)` |
21+
| ✅ Open Source (Others) | `Swift version 6.0.3 (swift-6.0.3-RELEASE)` |
22+
1123
Once you have installed the Open Source toolchain, you can install the Swift SDK for WebAssembly:
1224

1325
```bash
14-
$ swift sdk install "https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.3-RELEASE/swift-wasm-6.0.3-RELEASE-wasm32-unknown-wasi.artifactbundle.zip" --checksum "31d3585b06dd92de390bacc18527801480163188cd7473f492956b5e213a8618"
26+
swift sdk install "https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.3-RELEASE/swift-wasm-6.0.3-RELEASE-wasm32-unknown-wasi.artifactbundle.zip" --checksum "31d3585b06dd92de390bacc18527801480163188cd7473f492956b5e213a8618"
1527
```
1628

17-
After installing the Swift SDK, you can see the installed SDKs:
29+
After installing the Swift SDK, you can see `6.0.3-RELEASE-wasm32-unknown-wasi` in the Swift SDK list:
1830

1931
```bash
20-
$ swift sdk list
21-
<SDK name>
22-
...
32+
swift sdk list
2333
```
2434

2535
You can also find other SDKs from [the GitHub Releases page](https://github.com/swiftwasm/swift/releases).
2636

27-
Use the following shell snippet to query compatible Swift SDK for your current toolchain version:
28-
29-
```console
30-
(
31-
V="$(swiftc --version | head -n1)"; \
32-
TAG="$(curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -r --arg v "$V" '.[$v] | .[-1]')"; \
33-
curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG.json" | \
34-
jq -r '.["swift-sdks"]["wasm32-unknown-wasi"] | "swift sdk install \"\(.url)\" --checksum \"\(.checksum)\""'
35-
)
36-
```
37-
3837
## Hello, World
3938

4039
First, create a new directory for your project and navigate into it:
@@ -79,6 +78,27 @@ $ swift --version | head -n1
7978
| Open Source (macOS) | `Apple Swift version 6.0.3 (swift-6.0.3-RELEASE)` |
8079
| Open Source (Others) | `Swift version 6.0.3 (swift-6.0.3-RELEASE)` |
8180

81+
82+
### `<unknown>:0: error: module compiled with Swift 6.0.3 cannot be imported by the Swift x.y.z`
83+
84+
This error occurs when the Swift toolchain version you are using is different from the version of the Swift SDK you have installed.
85+
86+
To resolve this issue, you can either:
87+
88+
1. Switch the Swift toolchain to the same version as the Swift SDK you have installed. Check the [official guide](https://www.swift.org/install/macos/package_installer/) for how to switch the toolchain.
89+
2. Install the Swift SDK for the same version as the Swift toolchain you are using.
90+
Use the following shell snippet to query compatible Swift SDK for your current toolchain version:
91+
92+
```console
93+
(
94+
V="$(swiftc --version | head -n1)"; \
95+
TAG="$(curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -r --arg v "$V" '.[$v] | .[-1]')"; \
96+
curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG.json" | \
97+
jq -r '.["swift-sdks"]["wasm32-unknown-wasi"] | "swift sdk install \"\(.url)\" --checksum \"\(.checksum)\""'
98+
)
99+
```
100+
101+
82102
### What is the difference between the Swift Toolchain and the Swift SDK?
83103

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

0 commit comments

Comments
 (0)