问题
I'm writing simple swift command line tool application that automates some of my iOS Dev work. Everything is working except one thing - calling xcodebuild script.
My method looks like this:
func runTest(deviceName: String, os: String) {
killAllSimulators()
let sdk = "iphonesimulator"
let destination = "platform=iOS Simulator,name=" + deviceName + ",OS=" + os
let arguments = ["-workspace", workspace, "-scheme", scheme, "-sdk", sdk, "-destination", destination, "test"]
executor.executeCommand("xcodebuild", arguments: arguments)
}
deviceName is equal to "iPhone 4s", os is equal to "9.0", workspace and scheme variables are properly set.
My execute command has simple implementation:
func executeCommand(command: String, arguments: [String]) -> NSString? {
_ = NSProcessInfo.processInfo().processIdentifier
let pipe = NSPipe()
let fileHandle = pipe.fileHandleForReading
let task = NSTask()
task.launchPath = "/usr/bin/" + command
task.arguments = arguments
task.standardOutput = pipe
task.launch()
let data = fileHandle.readDataToEndOfFile()
fileHandle.closeFile()
return NSString(data: data, encoding: NSUTF8StringEncoding)
}
i got error that test failed because cdtool cannot compile. Thats very weird because exactly the same script called from terminal works..
Any ideas?
来源:https://stackoverflow.com/questions/31454008/calling-xcodebuild-from-swift-command-line-tool-fails