Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mortenjust/8ab8eb3774a02ac27c7cefc0af5c5244 to your computer and use it in GitHub Desktop.
Save mortenjust/8ab8eb3774a02ac27c7cefc0af5c5244 to your computer and use it in GitHub Desktop.
Self relaunch of Cocoa application (Swift version of https://gist.github.com/cdfmr/2204627)
let task = Process()
var args = [String]()
args.append("-c")
let bundle = Bundle.main.bundlePath
args.append("sleep 0.2; open \"\(bundle)\"")
task.launchPath = "/bin/sh"
task.arguments = args
task.launch()
NSApplication.shared().terminate(nil)
@KyLeggiero
Copy link

KyLeggiero commented Jul 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment