Skip to content

Swift WebAssembly runtime powered by WAMR

License

Notifications You must be signed in to change notification settings

swiftwasm/wamr-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wamr-swift

Swift WebAssembly runtime powered by WAMR

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:

.package(url: "https://github.com/swiftwasm/wamr-swift", from: "0.1.0"),

Example

import WAMR
import Foundation

let 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: [])