Unleash the power of invincible backends that auto-scale.get started
First you have to install the Swift-WASM package from https://book.swiftwasm.org/getting-started/setup.html.
You also have to install everything as described in Common tooling.
As Swift is currently a Tier 3 guest language, you can only call your whole Swift program from Golem exposed as a parameterless
The easiest way to get started once the tooling is installed is to use the
golem new command as described in the Quickstart.
If you prefer to do it from scratch, take the following simple Swift program saved into
let date = Date()
let calendar = Calendar.current
let year = calendar.component(.year, from: date)
And compile it to WASM using Swift-WASM:
/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc -target wasm32-unknown-wasi main.swift -o main.wasm -sdk /Library/Developer/Toolchains/swift-wasm-5.7.3-RELEASE.xctoolchain/usr/share/wasi-sysroot/
main.wasm is a WASM module not a component, so we have to use the tier 3 WASI adapter and
wasm-tools to convert it to a WASM component:
wasm-tools component new main.wasm -o template.wasm --adapt tier3/wasi_snapshot_preview1.wasm
wasi_snapshot_preview1.wasm describes the mapping from WASI Preview1 to Preview2. You must use the version of this file packaged together with
template.wasm is ready to be used with Golem.