Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Usage in a browser application
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:
- Create a directory for your project and make it current:
mkdir SwiftWasmApp && cd SwiftWasmApp
- Initialize the project from a template with
carton init --template basic
- Build the project and start the development server,
carton devcan be kept running during development:
- Open http://127.0.0.1:8080/ in your browser and a developer console
within it. You'll see
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.
Manual toolchain installation
Just pass a toolchain archive URL for the latest SwiftWasm 5.3 snapshot appropriate for your platform:
$ swiftenv install https://github.com/swiftwasm/swift/releases/download/swift-wasm-5.3.0-RELEASE/swift-wasm-5.3.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.3 (swiftlang-5.3.0) Target: x86_64-apple-darwin19.6.0
|Last commit: 4 days ago|
You may find interesting
0.10.0 - 2021-01-21T17:19:04
This release contains multiple breaking changes in preparation for enabling
await, when this feature is available in a stable SwiftWasm release. Namely:
JSClosureis no longer a subclass of
JSFunction. These classes are not related enough to keep them in the same class hierarchy. As a result, you can no longer call
JSClosureobjects directly from Swift. Call wrapped closures directly instead.
JSOneshotClosurefor closures that are going to be called only once. You don't need to manage references to these closures manually, as opposed to
JSClosure. However, they can only be called a single time from the JS side. Subsequent invocation attempts will raise a fatal error on the Swift side.
- Removed generic parameters on
JSPromise, now both success and failure values are always assumed to be of
JSValuetype. This also significantly simplifies type checking and allows callers to fully control type casting if needed.
- DOMKit? (#21)
Merged pull requests:
JSPromiseAPI (#115) via @kateinoigakukun
FUNDING.yml(#117) via @MaxDesiatov
- Major API change on
JSClosure(#113) via @kateinoigakukun
package.jsonto lockfileVersion 2 (#114) via @kateinoigakukun
inifrom 1.3.5 to 1.3.8 in
/Example(#111) via @dependabot[bot]
- Update doc comment in
JSTypedArray.swift(#110) via @MaxDesiatov