title: run xcode build command from a swift file
body: <p>I am using Xcode 7.3 and swift 2.2 </p>
  
  <p>i use the below command to run my ios ui test.</p>
  
  <pre><code>xcodebuild test -project ios-ui-automation-demo.xcodeproj -scheme ios-ui-automation-demo -destination 'platform=iOS Simulator,name=iPad Air'
  </code></pre>
  
  <p>I use the below code to run my Xcode build command in swift.</p>
  
  <pre><code>import Foundation
  
  func shell(launchPath: String, arguments: [AnyObject]) -&gt; String
  {
  let task = NSTask() //error here
  task.launchPath = launchPath
  task.arguments = arguments
  
  let pipe = NSPipe()
  task.standardOutput = pipe
  task.launch()
  
  let data = pipe.fileHandleForReading.readDataToEndOfFile()
  let output: String = NSString(data: data, encoding: NSUTF8StringEncoding)! as String
  
  return output
  }
  
  
  shell("xcodebuild", arguments: [ "test -project ios-ui-automation-demo.xcodeproj -scheme ios-ui-automation-demo -destination 'platform=iOS Simulator,name=iPad Air'"])
  </code></pre>
  
  <p>first of all this is showing error:</p>
  
  <pre><code> Use of unresolved identifier 'NSTask' //how i can fix it in ios swift file  
  </code></pre>
  
  <p>second is my code ok to run my command through swift?</p>