Skip to content

Commit fa880cd

Browse files
Add document
1 parent 227fb61 commit fa880cd

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ wamrTargets += [
113113
let package = Package(
114114
name: "WAMR",
115115
products: [
116+
.library(name: "WAMR", targets: ["WAMR"])
116117
],
117118
targets: wamrTargets + [
118119
.target(name: "wamr-demo", dependencies: [.target(name: "WAMR")]),

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1-
# WAMR
1+
# wamr-swift
22

3-
A description of this package.
3+
Swift WebAssembly runtime powered by WAMR
4+
5+
## Adding wamr-swift as a Dependency
6+
7+
To use the wamr-swift library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:
8+
9+
```swift
10+
.package(url: "https://github.com/swiftwasm/wamr-swift", from: "0.1.0"),
11+
```
12+
13+
14+
## Example
15+
16+
```swift
17+
import WAMR
18+
import Foundation
19+
20+
let inputFile = CommandLine.arguments[1]
21+
let binary = try Array(Data(contentsOf: URL(fileURLWithPath: inputFile)))
22+
23+
WasmRuntime.initialize()
24+
let module = try WasmModule(binary: binary)
25+
module.setWasiOptions(dirs: [], mapDirs: [], envs: [], args: [])
26+
let instance = try module.instantiate(stackSize: 64 * 1024)
27+
try instance.executeMain(args: [])
28+
```

0 commit comments

Comments
 (0)