developers: • If it compiles to Wasm, it can run in various environments • For platform developers: • With a Wasm runtime, it can support multiple languages →Good for program distribution formats
development in Swift • Community-driven e ff ort to make Swift WebAssembly-friendly • Provides a collection of products related to Wasm and Swift SwiftWasm Project Swift SDK for WebAssembly JavaScriptKit a JS interop library for Swift All compiler and standard library changes have been upstreamed! swiftwasm.org
Wasm + React.js Goodnotes Web fl owkey Web We were able to use 100%1 And more… ^1: https://forums.swift.org/t/web-workers-in-swift-wasm-via-da/60540 Yes! https://web.dev/case-studies/goodnotes
Create a new SwiftPM package $ swift package init --type executable --name Hello $ # Add carton build tool as a dependency $ swift package add-dependency https://github.com/swiftwasm/ carton --from 1.0.0 $ # Start dev server $ swift run carton dev $ # That’s it!
Swift for WebAssembly by Steven Van Impe • https://github.com/pwsacademy/swiftwasm-examples • Cross-Platform Swift: WebAssembly by Point-Free • https://www.pointfree.co/episodes/ep291-cross-platform-swift-webassembly • swift-react by @omochimetaru • https://github.com/omochi/swift-react Learn more about Swift on WebAssembly
development in Swift • Community-driven e ff ort to make Swift WebAssembly-friendly • Provides collection of products related to Wasm and Swift SwiftWasm Project Swift SDK for WebAssembly JavaScriptKit a JS interop library for Swift
development in Swift • Community-driven e ff ort to make Swift WebAssembly-friendly • Provides collection of products related to Wasm and Swift SwiftWasm Project Swift SDK for WebAssembly JavaScriptKit a JS interop library for Swift WasmKit a WebAssembly runtime for Swift NEW
only on swift-system. • No Foundation dependency • Compact and embeddable • Debug build completes in 5 seconds • Batteries included • WASI support, WAT parser, etc. A reasonably fast Wasm interpreter written in Swift github.com/swiftwasm/WasmKit
a host function that prints an i32 value. let hostPrint = HostFunction(type: FunctionType(parameters: [.i32])) { _, args in // This function is called from "print_add" in the WebAssembly module. print(args[0]) return [] } // Create a runtime importing the host function. let runtime = Runtime(hostModules: [ "printer": HostModule(functions: ["print_i32": hostPrint]) ]) let instance = try runtime.instantiate(module: module) // Invoke the exported function "print_add" _ = try runtime.invoke(instance, function: "print_add", with: [.i32(42), .i32(3)])
Call Greeter/greet Implements Greeter Distributed Actor protocol Process Execute plugin Greeters in isolated way but within a single process https://github.com/martiall/swift-subprocess-distributedactors Distributed Plugin Actor System Plugin Plugin