title: Swift + Xcode: use osascript in Mac App
body: <p>I want to ask if you can use osascript in swift/xcode when designing a Mac (Sierra) app. So I've basically just built an empty app using Xcode and swift.</p>
  
  <p>I would now like to use osascript to launch another app using osascript (preferred).</p>
  
  <p>So I've linked my button to ViewController.swift file.</p>
  
  <pre><code>@IBAction func launchApp(_ sender: NSButton) {
      let path = "/usr/bin/env"
      let arguments = ["osascript -e 'tell app \"iTunes\" to activate'"]
      let task = Process.launchedProcess(launchPath: path, arguments: arguments)
      task.waitUntilExit()
  }
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code> env: osascript -e 'tell app "iTunes" to activate': No such file or directory
  </code></pre>
  
  <p>I've also tried using path as /usr/bin/osascript and bash.</p>
  
  <p>Some guidance on this would be great!
  Thanks :)</p>