我最近发现我可以创建
Swift命令行脚本.
我决定看看我是否可以使用它来构建我的Xamarin项目.
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’,reason: ‘launch path not accessible’
这是我的脚本:
#!/usr/bin/env swift import Foundation print("Building Script") let fileManager = NSFileManager.defaultManager() let path = fileManager.currentDirectoryPath func shell(launchPath: String,arguments: [String] = []) -> NSString? { let task = NSTask() task.launchPath = launchPath task.arguments = arguments let pipe = NSPipe() task.standardOutput = pipe task.launch() let data = pipe.fileHandleForReading.readDataToEndOfFile() let output = NSString(data: data,encoding: NSUTF8StringEncoding) return output } if let output = shell("/Applications/Xamarin\\ Studio.app/Contents/MacOS/mdtool",arguments: ["-v build","\"--configuration:Beta|iPhone\"","MyApp.iOS.sln"]) { print(output) }
有什么想法吗?
我认为问题是你实际上想要执行shell并让它执行mdtool,而不是直接执行mdtool
原文链接:https://www.f2er.com/swift/319048.html尝试传递“/ bin / bash”作为启动路径,然后包含mdtool的路径作为参数字符串的一部分.