- v1.3.0 and master126.96.36.199.04.2
- v1.3.0 and masteriOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
Subprocess support for Swift
Some basic support for executing subprocesses, using Foundation.Process.
let url = /* url to the executable */ let runner = Runner(for: url) // execute and wait for results let result = runner.sync(["some", "arguments"]) print(result.status) print(result.stdout) print(result.stderr) // run in a different working directory runner.cwd = /* url to the directory */ let _ = runner.sync(["blah"]) // transfer execution to the subprocess runner.exec(url)
Rather than supplying the path to the executable explicitly, you can instead supply just a name, and have it looked up using the $PATH environment variable.
let runner = Runner(command: "name")