0

我正在使用 Xcode 7.3 和 swift 2.2

我使用以下命令运行我的 ios ui 测试。

xcodebuild test -project ios-ui-automation-demo.xcodeproj -scheme ios-ui-automation-demo -destination 'platform=iOS Simulator,name=iPad Air'

我使用下面的代码快速运行我的 Xcode 构建命令。

import Foundation

func shell(launchPath: String, arguments: [AnyObject]) -> 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'"])

首先这是显示错误:

 Use of unresolved identifier 'NSTask' //how i can fix it in ios swift file  

其次,我的代码可以通过 swift 运行我的命令吗?

4

0 回答 0