[ad_1]
I am trying to run xcrun simctl help
from inside a swift command line application. I am getting a “strange” error:
xcrun Unknown binary with magic 0x622f2123 at
/Applications/Xcode.app/Contents/Developer/usr/bin/simctl
magic 0x622f2123 is obviously a shell script signature. And indeed /Applications/Xcode.app/Contents/Developer/usr/bin/simctl is a bash script. I verified that this script is called by xcrun when invoked from the terminal. The following is my code:
let task = Process()
task.launchPath = "/usr/bin/xcrun"
task.arguments = ["simctl", "help"]
let outputPipe = Pipe()
let errorPipe = Pipe()
task.standardOutput = outputPipe
task.standardError = errorPipe
try? task.run()
let outputData = outputPipe.fileHandleForReading.readDataToEndOfFile()
let errorData = errorPipe.fileHandleForReading.readDataToEndOfFile()
let output = String(decoding: outputData, as: UTF8.self)
let error = String(decoding: errorData, as: UTF8.self)
print ("standard error:")
print ("\(error)")
print ("")
print ("standard output")
print ("\(output)")
print ("")
I do get the expected output on standardOutput
.
Thanks for any insight.
[ad_2]