[英]Not able to open an app using Process() in swift returns Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"
I have created two cocoa applications for macOS and I am trying to open one application from another on a button click but this returns an error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"
I even removed the app sandboxing in both the applications but still the same error, Any help would be appreciated.我为 macOS 创建了两个可可应用程序,我试图通过单击按钮从另一个应用程序打开一个应用程序,但这会返回错误
Domain=NSPOSIXErrorDomain Code=13 "Permission denied"
我什至删除了两个应用程序中的应用程序沙箱,但仍然是同样的错误,任何帮助将不胜感激。
Development Environment:开发环境:
OSX: 10.14.5 (Mojave)
Xcode: 11.2.1
Swift: 4.2
Code Sample:代码示例:
@IBAction func buttonAction(_ sender: Any) {
let task = Process.init()
task.launchPath = "/Users/JohnDoe/Desktop/ExampleApp.app"
task.arguments = ["--args", "hello"]
do{
try task.run()
}
catch{
print("Error: ", error)
}
task.waitUntilExit()
}
From the perspective of the shell the application bundle is a folder, you have to launch the executable从 shell 的角度来看,应用程序包是一个文件夹,您必须启动可执行文件
/Users/JohnDoe/Desktop/ExampleApp.app/Contents/MacOS/ExampleApp
Disabling the sandbox is required to run something with Process
需要禁用沙箱才能使用
Process
运行某些东西
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.