要在 xcodebuild 中运行 xcpretty 命令,我使用以下代码:
import Foundation
class Command{
func command(args: String...) -> Int32 {
let task = NSTask()
task.launchPath = "/usr/bin/env"
task.arguments = args
task.currentDirectoryPath = "/Users/Desktop/XCode/Test/"
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
let xcodebuildCommand = Command()
xcodebuildCommand.command("xcodebuild","test","-project","proj.xcodeproj","-scheme","projScheme","-destination","platform=iOS Simulator,name=iPad Air"," | /usr/local/bin/xcpretty --report html --output /Desktop/test_output/report.html")
错误是
xcodebuild: error: Unknown build action ' | /usr/local/bin/xcpretty --report html --output /Desktop/test_output/report.html'.
以下命令从终端正确运行:
xcodebuild test -project proj.xcodeproj.xcodeproj -scheme projScheme -destination 'platform=iOS Simulator,name=iPad Air' | xcpretty --repor html --output /pathToReportfolder/report.html