NSWorkspace API to open url failing in Sandboxed Environment with miscellaneous error occurred (OSStatus -54).

This method call fails when the app is sandboxed.


[[NSWorkspace sharedWorkspace]openURLs:@[url]
                      withApplicationAtURL:urlForApp
                                   options:NSWorkspaceLaunchDefault
                             configuration:@{}
                                     error:&error];


In my entitlements folder, I specify read/write permissions for User selected files, however that seems to make no difference. Is this behavior intentional, to not be able to launch another app to open a url?

Replies

Have you checked Console to see if there's any additional information? Usually the error messages for a sandbox violation can be quite helpful in solving the problem.

Yeah I didn't see anything useful though.


I have a *feeling* that this is intended. I was actually trying to do something with a Finder Sync extension's selected urls...which would improve the user experience for another app. I suppose the System doesn't consider selected files from a Finder Sync extension as getting "permission" from the user like drag and drop or an open/save panel....


I guess I could propose that if the user installs my Finder Sync extension in settings...that perhaps should be considered as permission? I have doubts that Apple would agree though.

Just FYI, -54 is

permErr
, so you’re definitely hitting an authorisation check.

Are you sure it’s the

url
value here that’s causing the problem? And not the
urlForApp
value?

For both URLs, what do you see when you call

-startAccessingSecurityScopedResource
?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"