NSWorkSpace

Hi,
I have an app that relies on NSWorkspace in order to load the content of audio-CDs when they are available.
Since in System Prefs > CD/DVD I have set my app as the default one, when I insert a CD, my app opens and loads its content.

Again, if I open my app and then insert a CD, it will be loaded.

The problem I have is when I open my app when a CD is already mounted on the desktop.
If the app is not sandboxed the app loads the CD by retrieving the volume and sending such folderitem to the relevant parsing-code.
But when the app is sandboxed that workaround does not work, so nothing happens. The only way is to select the CD thru an open-dialog or dropping it into the app’window.
Is there a way to “refresh” NSWorkSpace, or to grant permissions or anything else so that the CD gets automatically loaded?

BTW: I reviewed the app capabilities in AppWrapper but I can’t see anything relevant to add.

[edit] I set iTunes as default app in system Prefs. Opening iTunes when a CD is already on the desktop, iTunes loads it. So there should be a way to do it.

Thank you.

not sure, Apple apps can have much more privileges than “normal” dev app !

@Jean-Yves Pochez Apple apps can have much more privileges than “normal” dev app.

I guessed something like that, yet I’ll try and see if I can find a way.

AFAIK iTunes isn’t Sandboxed, for exactly this reason. Now technically there is a way; you’d need full access to the machine in order to get the optical volume (AFAIK), and Apple will not approve your App on the Mac App Store with this capability.

Apple have been known to add special entitlements, but they’re also not known for sharing said special tasks. Many of them are considered “Private” and you’ll not be approved on the App Store for using it.

If you’re not shipping on the App Store, then don’t Sandbox.

So be it although it isn’t fair.

Anyway, for this situations I’ll popup a message offering the user to open the optical volume, and if she/he agrees the app will popup another openselectDialog with the right disk already selected so that the user has got only to press Return. Actually I’d have liked to popup a third and even a forth dialog, but I run short of ideas.

Thank you for settling the matter.

Use the openDialog.prompt to display your message within the Open dialog. You save a dialog and step for the customer.

Remember they’ll probably already be fed up with allow/deny dialogs that Apple loves almost as much as emoji!

Yep, I’ll do it. Thanks.

You could let the user add permission in the Preferences/Security&Privacy for you app. (Access to all Files).
Thay may work for you.

And I really find that unfair and annoying…

@Christoph De Vocht You could let the user add permission in the Preferences/Security&Privacy for you app. (Access to all Files).

Thanks for the hint, but on my MPB (Mojave) I cannot see “Access to all Files”.
I tried Full Disk Access and Accessibility, but it won’t work.