4

I am trying to open a specific folder when a user clicks on a menu item in the Finder Sync Extension I am writing. I know there are many similar questions posted because I have looked at them but none of the solutions are working in my application.

Here is the folder I am trying to open:

let folder = "/Users/username/some/folder"

This post, Show folder's contents in finder using Swift, suggested doing the following:

NSWorkspace.shared().selectFile(nil, inFileViewerRootedAtPath: folder)

When I tired this method, the menu item does nothing when it is clicked.

There are many other posts I have looked at and I have also tried the following methods but I haven't had anything work yet.

NSWorkspace.shared().activateFileViewerSelecting([URL(fileURLWithPath: safeZone, isDirectory: true)])

This results in the containing folder "some" being opened and the folder I actually wanted to open "folder" is just highlighted.

NSWorkspace.shared().openFile(safeZone)

When I tired this method, the menu item does nothing when it is clicked.

NSWorkspace.shared().open(URL(fileURLWithPath: safeZone, isDirectory: true))

When I tried this method, I got a message from Finder stating:

The application “MyAppFileSyncExtension” does not have permission to open “folder.”

Is there some way via Xcode to give the extension more permissions? I know my parent app can read and write to this folder no problem.

NSWorkspace.shared().openFile(folder, withApplication: "Finder")

When I tired this method, the menu item does nothing when it is clicked.

I am guessing that none of these methods are working because I am trying to do this from Finder Sync Extension. Does anyone know how to get around this issue?

UPDATE

I tested those methods from the parent application and most of them work. The question is how to create this type of behavior from a Finder Sync Extension. Any help would be greatly appreciated.

Alec
  • 666
  • 8
  • 23
  • 1
    Have you setup the proper entitlements so the extension can access the folders? – l'L'l Jul 14 '17 at 16:11
  • 1
    @I'L'I I don't think so. How do I do that? I had an existing application which could access the folders and add a Finder Sync Extension with default settings to the existing application. How do I set up the entitlements so that the extension can have the same access as the parent application? – Alec Jul 14 '17 at 19:07

0 Answers0