从另一个运行可执行文件

时间:2016-06-17 12:48:24

标签: ios iphone xcode swift xcode7

我试图在swift中创建可执行文件以运行带有参数的主可执行文件我想这样做.sh文件:

dir=$(dirname "$0")
exec "${dir}"/Main "$@"

我如何为iOS部署这样的东西

1 个答案:

答案 0 :(得分:-2)

您可以使用NSTask

func shell(args: String...) -> Int32 {
    let task = NSTask()
    task.launchPath = "/usr/bin/env"
    task.arguments = args
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

let appPath = dir + "Main"
shell(appPath, "arg1", "arg2")
相关问题