Skip to content

Commit a0df208

Browse files
authored
Merge pull request #1162 from MaxDesiatov/update-wasm-6.2
Update `wasm-getting-started.md` for 6.2 release
2 parents 6119dfa + f5638d8 commit a0df208

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

documentation/articles/wasm-getting-started.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,29 @@ WebAssembly support in Swift started out as a community project. Any instruction
1313
standardized ABI and system interfaces, and from its inception Wasm support in Swift targeted [WebAssembly System
1414
Interface](https://wasi.dev/), which made porting Swift core libraries to this platform much easier.
1515

16-
With Swift 6.2 and development snapshots you can easily cross-compile and run Wasm modules with Swift SDKs for WASI distributed on [swift.org](https://swift.org/download).
16+
Starting with Swift 6.2 and development snapshots you can easily cross-compile and run Wasm modules with Swift SDKs for Wasm distributed on [swift.org](https://swift.org/download).
1717
The distributed artifact bundles also include support for the experimental Embedded Swift mode.
1818

1919
## Installation
2020

21-
1. [Install `swiftly` per the instructions](https://www.swift.org/install/) for the platform that you're bulding on.
21+
{% assign last_release = site.data.builds.swift_releases.last %}
22+
{% assign platform = last_release.platforms | where: 'name', 'Wasm'| first %}
23+
{% assign release_name = last_release.name %}
24+
{% assign tag = last_release.tag %}
25+
{% assign tag_downcase = last_release.tag | downcase %}
2226

23-
2. Install latest 6.2 development snapshot with `swiftly install 6.2-snapshot`, note the exact snapshot date component in the output of this command.
27+
{% assign base_url = "https://download.swift.org/" | append: tag_downcase | append: "/wasm/" | append: tag | append: "/" | append: tag %}
28+
{% assign command = "swift sdk install " | append: base_url | append: "_wasm.artifactbundle.tar.gz --checksum " | append: platform.checksum %}
2429

25-
3. Select the installed toolchain with `swiftly use 6.2-snapshot`.
30+
1. [Install `swiftly` per the instructions](https://www.swift.org/install/) for the platform that you're bulding on.
2631

27-
4. Navigate to [the downloads page](https://www.swift.org/download/) and find the “Swift SDK for WASI” section. Find a URL of a version that exactly matches the version from step 2.
28-
If the corresponding snapshot version is not available for the Swift SDK, you’ll have to install the matching toolchain first.
32+
2. Install Swift {{ release_name }} with `swiftly install {{ release_name }}`, note the exact snapshot date component in the output of this command.
2933

30-
5. Press "Copy install command" link for the selected Swift SDK to get the installation command, then run it in your terminal application. The command would look like this:
34+
3. Select the installed toolchain with `swiftly use {{ release_name }}`.
3135

36+
4. Run a command in your terminal application to install Swift SDKs for Wasm.
3237
```
33-
swift sdk install <swift_sdk_url> --checksum <checksum_value>
38+
{{ command }}
3439
```
3540
3641
6. Run `swift sdk list` to verify the Swift SDK was installed and note its ID in the output. Two Swift SDKs will be installed,
@@ -41,7 +46,7 @@ one with support for all Swift features, and the other with a subset of features
4146
| `swift-<version>_wasm` | Supports all Swift features |
4247
| `swift-<version>_wasm-embedded` | Supports a subset of features allowed in the experimental [Embedded Swift mode](#embedded-swift-support) |
4348
44-
7. In the future, after installing or selecting a new version of the toolchain with `swiftly` make sure to follow steps 3-6 to install a Swift SDK exactly matching the toolchain version.
49+
7. In the future, after installing or selecting a new version of the toolchain with `swiftly` make sure to install and use an exactly matching Swift SDK version.
4550
4651
## Building and Running
4752
@@ -72,15 +77,15 @@ struct wasi_test {
7277
Build your package with the following command, substituting the ID from step 5 of [the "Installation" section](#installation) above.
7378

7479
```
75-
swift build --swift-sdk <swift_sdk_id>
80+
swift build --swift-sdk {{ tag }}_wasm
7681
```
7782

78-
Recent toolchain snapshots that are compatible with Swift SDKs for WASI also include
83+
Recent toolchain snapshots that are compatible with Swift SDKs for Wasm also include
7984
[WasmKit](https://github.com/swiftwasm/wasmkit/), which is a Wasm runtime that `swift run` can delegate to for
8085
execution. To run the freshly built module, use `swift run` with the same `--swift-sdk` option:
8186

8287
```
83-
swift run --swift-sdk <swift_sdk_id>
88+
swift run --swift-sdk {{ tag }}_wasm
8489
```
8590

8691
You should see the following output:
@@ -99,5 +104,14 @@ Hello from WASI!
99104
allowing the toolchain to produce Wasm binaries that are multiple orders of magnitude smaller. One of the Swift SDKs in the artifact bundle you've installed
100105
with the `swift sdk install` command is tailored specifically for Embedded Swift.
101106

102-
To build with Embedded Swift SDK, pass its ID as noted in `swift sdk list` output (which has an `-embedded` suffix) in the `--swift-sdk` option.
107+
To build with Embedded Swift SDK, pass its ID as noted in `swift sdk list` output (which has an `-embedded` suffix) in the `--swift-sdk` option. For example:
108+
109+
```
110+
swift build --swift-sdk {{ tag }}_wasm-embedded
111+
```
112+
113+
or
103114

115+
```
116+
swift run --swift-sdk {{ tag }}_wasm-embedded
117+
```

0 commit comments

Comments
 (0)