You may have seen some posts about WebAssembly support in Swift on these forums previously. These were mostly questions and discussions about the toolchain development. Today I'm excited to make an announcement first and foremost for end users of Swift interested in applying it on more platforms.
As a culmination of hard work from many people, the first stable release of SwiftWasm 5.3 is available. It allows you to compile your Swift code to WebAssembly, and to interact with the host WebAssembly environment through libraries that the SwiftWasm team maintains. WebAssembly is supported in all recently released major browsers, which means you can build browser apps written purely in Swift (although some JavaScript glue code invisible to users is required under the hood). Non-browser Wasm hosts are also supported, such as Node.js, Wasmer, or any other WASI-compatible hosts.
It is available as a signed .pkg installer for macOS (only Intel for now, but Apple Silicon builds are coming soon), and via swiftenv
-compatible archives for Intel-based Ubuntu 18.04 and 20.04. We also provide Docker images for these Ubuntu releases.
While these installation methods may be useful for advanced use cases, carton
is our recommended development tool that simplifies toolchain installation, building, testing, and packaging of SwiftWasm apps running in the browser. It is available via Homebrew and also for same Linux distributions as SwiftWasm itself. We also have a GitHub Action to make it easy to publish SwiftWasm apps with carton
. Please follow our guide in the SwiftWasm book to get started with carton
.
Important to note, that while SwiftWasm may be appropriate for general use, it is not directly affiliated with the upstream Swift project. Our 5.3.0 release is based on the upstream 5.3.0 release of Swift, but applies patches necessary to enable WebAssembly support on top of that in our fork. With our limited resources we're working on making these changes available upstream, in parallel with the development of other SwiftWasm libraries and tools. Try SwiftWasm in your projects, and let us know of your experience. All feedback and contributions are very welcome and help the ecosystem to move forward!
Lastly, I need to mention that I deeply appreciate the work of the SwiftWasm team (Zhouwei Zhang, @kateinoigakukun, @carsonkatri, @j-f1, @RayZhao), upstream Swift contributors (@millenomi, @compnerd, @Michael_Gottesman, @ddunbar, Anders Bertelrud, @Aciid, @NeoNacho, Mattt), our GitHub sponsors, early adopters, and many others I probably forgot to mention. Without your help this project wouldn't be possible!