Starting with SwiftWasm 5.5 you can use
JSPromise objects. This requires
a few additional steps though (you can skip these steps if your app depends on
TaskAPIs (most likely in
TaskAPIs (again, most likely in
Then you can
await on the
value property of
JSPromise instances, like in the example below:
If you need to support older browser versions, you'll have to build with
when compiling. This should lower browser requirements to these versions:
Not all of these versions are tested on regular basis though, compatibility reports are very welcome!
As a part of these steps
carton via Homebrew on macOS (you can also use the
Docker image if you prefer to run the build steps on Linux). Assuming you already have Homebrew
brew install swiftwasm/tap/carton
If you had
carton installed before this, make sure you have version 0.6.1 or greater:
mkdir SwiftWasmApp && cd SwiftWasmApp
carton init --template basic
carton devcan be kept running during development:
Hello, world!output in the console. You can edit the app source code in your favorite editor and save it,
cartonwill immediately rebuild the app and reload all browser tabs that have the app open.
You can also build your project with webpack.js and a manually installed SwiftWasm toolchain. Please see the following sections and the Example directory for more information in this more advanced use case.
Just pass a toolchain archive URL for the latest SwiftWasm 5.5 release appropriate for your platform:
$ swiftenv install https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.5.0-RELEASE/swift-wasm-5.5.0-RELEASE-macos_x86_64.pkg
You can also use the
install-toolchain.sh helper script that uses a hardcoded toolchain snapshot:
$ ./scripts/install-toolchain.sh $ swift --version Swift version 5.5 (swiftlang-5.5.0) Target: arm64-apple-darwin20.6.0
|Last commit: 1 week ago|
This is a bugfix release that removes a requirement for macOS Monterey in
Package.swift for this package.
Merged pull requests: