-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
227fb61
commit fa880cd
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: []) | ||
``` |