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
Copy file name to clipboardExpand all lines: content/wasm-languages/swift.md
+19-12Lines changed: 19 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,10 @@ But it is no longer just for iOS apps.
14
14
Thanks to a recent community-led project, it is possible to [compile Swift into WebAssembly](https://swiftwasm.org/)
15
15
destined either for the browser or for a WASI environment.
16
16
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
+
17
21
## Available Implementations
18
22
19
23
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:
32
36
33
37
```
34
38
$ 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
37
41
```
38
42
39
43
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
69
73
The simplest Swift program for Spin (or Wagi) looks like this:
70
74
71
75
```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!")
74
78
```
75
79
76
80
To compile, set the target to `wasm32-unknown-wasi` (which ensures that WASI support is enabled):
@@ -91,19 +95,22 @@ Hello, World!
91
95
To run it as a Spin web application, we can add a `spin.toml` that looks like this:
0 commit comments