Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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()
}

like image 856
Mohit Avatar asked Sep 13 '25 23:09

Mohit


1 Answers

From the perspective of the shell the application bundle is a folder, you have to launch the executable

/Users/JohnDoe/Desktop/ExampleApp.app/Contents/MacOS/ExampleApp

Disabling the sandbox is required to run something with Process

like image 51
vadian Avatar answered Sep 16 '25 12:09

vadian