【发布时间】:2019-06-17 07:55:15
【问题描述】:
我正在使用 Swift 为运行 iOS 12 的越狱设备制作 iOS 应用。
最近我提出了一个问题,我自己回答了,我在其中询问了run command line tasks with Swift in iOS的方法。
但正如你所见,我还没有完成,因为我可以使用 NSTask,但它在运行应用程序时崩溃。
基本上,我有一个NSTask.h file,它允许我将 NSTask 与 Swift 一起使用。
所以,为了启动一个任务,我做了以下函数:
func task(launchPath: String, arguments: String...) {
let task = NSTask.init()
task?.setLaunchPath(launchPath)
task?.arguments = arguments
// Create a Pipe and make the task
// put all the output there
let pipe = Pipe()
task?.standardOutput = pipe
// Launch the task
task?.launch()
task?.waitUntilExit()
}
然后像这样调用函数:
task(launchPath: "/usr/bin", arguments: "git clone https://github.com/lz4/lz4.git")
问题是当我运行该应用程序时,它崩溃并打印以下错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't posix_spawn: error 13'
我可以做些什么来修复这个错误?
提前致谢。
编辑:顺便说一句,我忘了提到我使用桥接头访问NSTask.h文件。
【问题讨论】:
标签: ios swift jailbreak nstask