3

all,

I am having a need to relaunch my app. Googled and got two suggestions:
1. https://gist.github.com/2204627
got the lsboxd message directly.

2. http://13bold.com/tutorials/relaunching-your-application/
got LSOpenFromURLSpec() returned -10827 ... message

both of them are related to Sandbox.

I want to know, is there any way to relaunch my app with sandbox deployed? Thanks!

Terry
  • 337
  • 2
  • 9

1 Answers1

10

A sandboxed application can launch a new copy of itself using NSWorkspace's launchAppWithBundleIdentifier:; pass in options NSWorkspaceLaunchAsync, NSWorkspaceLaunchNewInstance to asynchronously create a new process running your app and after the call returns terminate the current process (or make the call as part of responding to a NSApplicationWillTerminateNotification).

CRD
  • 52,522
  • 5
  • 70
  • 86
  • I've tried the launchAppWithBundleIdentifier:... method simply with "com.apple.dock", it seemed working, but still got the "lsboxd: @AE ..." in the Console. I am not sure whether it conflicts the sandbox restriction or not? – Terry Sep 10 '12 at 04:30
  • @Terry - Maybe I misunderstood, you shouldn't be doing this with "com.apple.dock" it is a method for your own app to relaunch itself when running under the sandbox. That said maybe the method no longer works, the sandbox is notoriously fickle and should be avoided if possible. The method comes from a thread on the developer forums - search for "launchAppWithBundleIdentifier" earlier this year - and in it an Apple engineer confirms the process. If it is no longer working post in that thread and maybe the same Apple engineer will respond. – CRD Sep 10 '12 at 18:30