Skip to content

Instantly share code, notes, and snippets.

@kerker00
Last active October 3, 2018 19:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save kerker00/63d52c7b0e6a5df1d2bc to your computer and use it in GitHub Desktop.
Save kerker00/63d52c7b0e6a5df1d2bc to your computer and use it in GitHub Desktop.
Self relaunch of Cocoa application (Swift version of https://gist.github.com/cdfmr/2204627)
var task = NSTask()
var args: NSMutableArray
args = NSMutableArray()
args.addObject("-c")
args.addObject("sleep 0.2; open \"\(NSBundle.mainBundle().bundlePath())\"")
task.setLaunchPath("/bin/sh")
task.setArguments(args)
task.launch()
NSApplication.sharedApplication().terminate(nil)
@ericdke
Copy link

ericdke commented Mar 11, 2015

Hello! I've updated your Gist for Swift 1.2, new version is here: https://gist.github.com/ericdke/75a42dc8d4c5f61df7d9

@mortenjust
Copy link

@KyLeggiero
Copy link

@Agm91
Copy link

Agm91 commented Oct 3, 2018

is there the a way to this for iOS app?

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