Skip to content

Commit

Permalink
Add document
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Dec 21, 2020
1 parent 227fb61 commit fa880cd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ wamrTargets += [
let package = Package(
name: "WAMR",
products: [
.library(name: "WAMR", targets: ["WAMR"])
],
targets: wamrTargets + [
.target(name: "wamr-demo", dependencies: [.target(name: "WAMR")]),
Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# WAMR
# wamr-swift

A description of this package.
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:

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


## Example

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

0 comments on commit fa880cd

Please sign in to comment.