NSWorkspace.shared.openApplication Permission Issue

Hello,

I replaced the following line of code:

NSWorkspace.shared.launchApplication(newPath)

With this:

let url = URL(fileURLWithPath: newPath)

let configuration = NSWorkspace.OpenConfiguration() configuration.arguments = [newPath]

NSWorkspace.shared.openApplication(at: url, configuration: configuration, completionHandler: nil)

...because 'launchApplication' is deprecated in macOS 11.0.

The code compiles without issue, however on login I receive an error stating that "[APP_HELPER] does not have permission to launch [APP]". I had no such issue when using 'launchApplication', and this only occurred when changing it to 'openApplication'.

I'm sure I'm missing something obvious here with regards to sandboxing and permissions for my helper app to launch my app, but I'm lost.

Any ideas?

+1, I'm facing the very same issue. Below is the thrown error:

Error Domain=NSOSStatusErrorDomain Code=-54 "permErr: permissions error (on file open)" UserInfo={_LSLine=3845, _LSFunction=_LSOpenStuffCallLocal}}}

Not sure what permission I'm omitting. Add to the weirdness: with the same method I can open "/Application/SomeApp.app" without an issue, but I can't open my main app from a bundled login item (the typical app launcher).

I was following an example invoking the inner binary via "Contents/MacOS/<binary_name>". Instead, passing the path to the *.app container to .openApplication() resolved my permission issue.

Code here:

https://github.com/passepartoutvpn/passepartout-apple/commit/b966826f19f5d57d0c942860b5feb7b65befee8f

NSWorkspace.shared.openApplication Permission Issue
 
 
Q