Skip to content

Commit 68674f1

Browse files
authored
Merge pull request #1407 from fermyon/docs/wasm-lang-swift-updates
docs(wasm-languages): swift updates
2 parents bc31d93 + 324ca6e commit 68674f1

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

content/wasm-languages/swift.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ But it is no longer just for iOS apps.
1414
Thanks to a recent community-led project, it is possible to [compile Swift into WebAssembly](https://swiftwasm.org/)
1515
destined either for the browser or for a WASI environment.
1616

17+
## Compatibility
18+
19+
The latest [5.10 version of the SwiftWasm tools](https://book.swiftwasm.org/getting-started/setup.html#installation---latest-release-swiftwasm-510) uses an older version of wasi-libc that is not supported by Spin 3+. Therefore, Spin 2.x is necessary for running example Swift apps at this time. Assuming Swift 6.0 ships with an updated wasi-libc version, compatibility with Spin 3+ should then be possible.
20+
1721
## Available Implementations
1822

1923
The [SwiftWasm](https://swiftwasm.org/) project compiles Swift to WebAssembly. While this is a community-led project, the [stated goal](https://book.swiftwasm.org/index.html) of the project is:
@@ -32,8 +36,8 @@ Once that is done, the `swift` tool should report SwiftWasm support:
3236

3337
```
3438
$ swift --version
35-
SwiftWasm Swift version 5.5 (swiftlang-5.5.0)
36-
Target: arm64-apple-darwin21.1.0
39+
SwiftWasm Swift version 5.10-dev (LLVM e98989b1092ff3a, Swift 23e8e340a7a32a7)
40+
Target: arm64-apple-darwin24.0.0
3741
```
3842

3943
From there, the `swift` tool works as usual.
@@ -69,8 +73,8 @@ Once you have installed SwiftWasm, it is easy to build applications for the Ferm
6973
The simplest Swift program for Spin (or Wagi) looks like this:
7074

7175
```swift
72-
print("content-type: text/plain\n\n")
73-
print("Hello, World!\n")
76+
print("content-type: text/plain\n")
77+
print("Hello, World!")
7478
```
7579

7680
To compile, set the target to `wasm32-unknown-wasi` (which ensures that WASI support is enabled):
@@ -91,19 +95,22 @@ Hello, World!
9195
To run it as a Spin web application, we can add a `spin.toml` that looks like this:
9296

9397
```toml
94-
spin_version = "1"
95-
authors = ["Fermyon Engineering <[email protected]>"]
96-
description = "Hello world app."
98+
spin_manifest_version = 2
99+
100+
[application]
97101
name = "spin-hello"
98-
trigger = { type = "http", base = "/" }
99102
version = "1.0.0"
103+
description = "Hello world app."
104+
authors = ["Fermyon Engineering <[email protected]>"]
100105

101-
[[component]]
102-
id = "hello"
103-
source = "hello.wasm"
104-
[component.trigger]
106+
[[trigger.http]]
107+
id = "trigger-hello"
108+
component = "hello"
105109
route = "/"
106110
executor = { type = "wagi" }
111+
112+
[component.hello]
113+
source = "hello.wasm"
107114
```
108115

109116
Note that we use the `wagi` executor.

0 commit comments

Comments
 (0)