Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swiftwasm/wamr-swift
Swift WebAssembly runtime powered by WAMR
https://github.com/swiftwasm/wamr-swift
swift swiftwasm wasi wasm webassembly webassembly-runtime
Last synced: 13 days ago
JSON representation
Swift WebAssembly runtime powered by WAMR
- Host: GitHub
- URL: https://github.com/swiftwasm/wamr-swift
- Owner: swiftwasm
- License: apache-2.0
- Created: 2020-12-21T01:55:52.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-31T11:36:23.000Z (over 3 years ago)
- Last Synced: 2024-04-13T21:55:32.448Z (7 months ago)
- Topics: swift, swiftwasm, wasi, wasm, webassembly, webassembly-runtime
- Language: Swift
- Homepage:
- Size: 43.9 KB
- Stars: 31
- Watchers: 8
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# wamr-swift
Swift WebAssembly runtime powered by [WAMR](https://github.com/bytecodealliance/wasm-micro-runtime).
## Adding wamr-swift as a Dependency
To use the wamr-swift library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:
```swift
let package = Package(
name: "Example",
dependencies: [
.package(name: "WAMR", url: "https://github.com/swiftwasm/wamr-swift", from: "0.1.1"),
],
targets: [
.target(name: "Example", dependencies: ["WAMR"]),
]
)```
## Example
```swift
import WAMR
import Foundationlet inputFile = CommandLine.arguments[1]
let binary = try Array(Data(contentsOf: URL(fileURLWithPath: inputFile)))WasmRuntime.initialize()
let module = try WasmModule(binary: binary)
module.setWasiOptions(dirs: [], mapDirs: [], envs: [], args: [])
let instance = try module.instantiate(stackSize: 64 * 1024)
try instance.executeMain(args: [])
```