Opening a Volume Folder in Finder

I'm trying to open a folder from my app, but when I call selectFile(_:inFileViewerRootedAtPath:) with a fullPath set to nil and rootFullPath set to a volume mount point in Volumes or a sub-folder of Volumes, it always returns false and I see the following errors in Console:

error	22:31:16.832634-0700	CoreServicesUIAgent	Failed to open document <private> because the calling process does not have sandbox access at its location.
error	22:31:16.833025-0700	CoreServicesUIAgent	LAUNCH: Launch failed in CSUI with error Error Domain=NSOSStatusErrorDomain Code=-54 "permErr: permissions error (on file open)" UserInfo={_LSLine=4101, _LSFunction=_LSOpenStuffCallLocal}

The related code is simple:

    @IBAction func open(_ sender: NSMenuItem)  {
        let volume = sender.representedObject as! Volume
        if !NSWorkspace.shared.selectFile(nil, inFileViewerRootedAtPath: volume.url.path) {
            print("could not open \(volume.url.path)")
        }
    }

This may be related to #190213022, however, there is no discussion there.

Passing the same directory path as for fullPath as rootFullPath opens a the parent folder of the one I'm interested in with the folder I'd like to open selected. That's nice, but not what I want to do.

If I know the name of a file on the volume and pass that in fullPath, the folder will be opened as expected. My app is sandboxed and has no read permissions for any files or folders. I don't have any need to read any user files, so I'd prefer not to have to add a request for full disk access just to display a folder.

As far as I can tell activateFileViewerSelecting(_:) can only select files and cannot open a folder with no files selected. If I did know the name of a file in the folder, this will open the folder with that file selected, even if it's in the root of a mounted volume. It seems like an odd restriction to allow opening a Folder with a file selected but not the same Folder with no file selected.

open(_:) and friends produce an alert indicating I don't have permission to open the folder. This happens regardless of whether I set .promptsUserIfNeeded or not.

I could go the AppleEvent route and tell Finder to open the folder, but again, that would require a permission I don't currently have, don't need, and don't really want, plus, that seems rather silly.

Are there any other options? This is a convenient "Show in Finder" type feature. I'd like the same behavior as when you select a volume in Disk Utility and select "Show in Finder" (which opens a folder at the root of the volume).

Opening a Volume Folder in Finder
 
 
Q