title: How to open a folder via Finder using Swift in Xcode from a Finder Sync Extension
body: <p>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.</p>
  
  <p>Here is the folder I am trying to open:</p>
  
  <pre><code>let folder = "/Users/username/some/folder"
  </code></pre>
  
  <p>This post, <a href="https://stackoverflow.com/questions/30738052/show-folders-contents-in-finder-using-swift">Show folder&#39;s contents in finder using Swift</a>, suggested doing the following:</p>
  
  <pre><code>NSWorkspace.shared().selectFile(nil, inFileViewerRootedAtPath: folder)
  </code></pre>
  
  <p>When I tired this method, the menu item does nothing when it is clicked.</p>
  
  <p>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.</p>
  
  <pre><code>NSWorkspace.shared().activateFileViewerSelecting([URL(fileURLWithPath: safeZone, isDirectory: true)])
  </code></pre>
  
  <p>This results in the containing folder "some" being opened and the folder I actually wanted to open "folder" is just highlighted.</p>
  
  <pre><code>NSWorkspace.shared().openFile(safeZone)
  </code></pre>
  
  <p>When I tired this method, the menu item does nothing when it is clicked.</p>
  
  <pre><code>NSWorkspace.shared().open(URL(fileURLWithPath: safeZone, isDirectory: true))
  </code></pre>
  
  <p>When I tried this method, I got a message from Finder stating: </p>
  
  <pre><code>The application “MyAppFileSyncExtension” does not have permission to open “folder.”
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>NSWorkspace.shared().openFile(folder, withApplication: "Finder")
  </code></pre>
  
  <p>When I tired this method, the menu item does nothing when it is clicked.</p>
  
  <p>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?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>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.</p>