title: Loading a local .scpt file in my Swift project causes error
body: <p>I'm testing out a Mac app, trying to load my <code>hello.scpt</code> file which is in my Xcode project in the <code>/scripts</code> directory</p>
  <pre><code># even though it's in the scripts folder, `path` will be nil unless the resource value is &quot;hello&quot;
  let path = Bundle.main.path(forResource: &quot;hello&quot;, ofType: &quot;scpt&quot;)
  let url = URL(fileURLWithPath: path!)
  let scriptObject = try? NSUserAppleScriptTask(url: url)
  scriptObject?.execute { handler in
       print(handler)
  }
  </code></pre>
  <p>Error:</p>
  <blockquote>
  <p>Optional(Error Domain=NSCocoaErrorDomain Code=257 &quot;The file
  “hello.scpt” couldn’t be opened because you don’t have permission to
  view it.&quot;
  UserInfo={NSURL=file:///Users/me/Library/Developer/Xcode/DerivedData/app-gidwjssyedvwuyfcncsjkfroqdjp/Build/Products/Debug/myApp.app/Contents/Resources/test.scpt,
  NSLocalizedFailureReason=Script file is not in the application scripts
  folder.})</p>
  </blockquote>
  <p>I tried vadian's response below, creating a folder called <code>NSApplicationScriptsDirectory</code> which seems weird. Also tried specifying in the <code>Info.plist</code> <code>NSApplicationScriptsDirectory</code> as the key and different variants to the <code>./scripts/</code> file as the key but no luck here.</p>
  <p>This is a simple sandboxed app with a Hello World script that just prints &quot;Hello world&quot; to <code>stdout</code></p>
  <p>How can I load this AppleScript in and get it to work without the error?</p>
  <p>Thanks!</p>
  <p><strong>Edit:</strong> I've also tried putting it in my <code>~/Library/Scripts</code> folder as <code>hello.scpt</code> but that doesn't work either</p>