SwiftRunner can execute the string written in Swift on runtime.
import SwiftRunner
let text = "print(\"hello!\")"
let result = SwiftRunner.shared.run(string: text) // => hello!
switch result {
case .success(let stream):
stream.output // => "hello!\n"
case .failure(let error): break
}
- Evaluate text written in Swift on runtime
- Work on MacOS & Linux
- Security measures
Waiting for your great pull requests :D
This project contains a playground file. So you can try the features.
To try immediately, you can run the following:
$ cd <your working directory>
$ curl -sf https://raw.githubusercontent.com/tattn/SwiftRunner/master/scripts/try-playground.sh | sh -s
After building (⌘+B), you can try it :)
- Xcode 8.0+
- Swift 3.0+
import PackageDescription
let package = Package(
name: "MyProject",
targets: [],
dependencies: [
.Package(url: "https://github.com/tattn/SwiftRunner.git", majorVersion: 1)
]
)
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
SwiftRunner is released under the MIT license. See LICENSE for details.