How can I run a terminal command in my swift menu bar app?
问题 I have made a menu bar app and I want this command to be run on press rm -rf ~/.Trash/* The code I currently have is this: @IBAction func toggleClicked(sender: NSMenuItem) { let task = NSTask() task.launchPath = "/bin/sh" task.arguments = ["rm", "-rf", "~/.Trash/*"] task.launch() task.waitUntilExit() } But when I run this, I get the following error: /bin/rm: /bin/rm: cannot execute binary file I dont really understand why I'm getting this error since I can open terminal and run /bin/sh, then