Sandboxed Helper App can not launch the correct parent application

1.1k views Asked by At

I'm using this tutorial to add a Login Item to my application. Most of it works as expected, I've managed to create a sandboxed helper app and register it with the launch services, so it is launched on login as it should be.

Now the problem is that the tutorial is not very specific on how you are supposed to launch your main application bundle from within this helper app. It includes only this:

[[NSWorkspace sharedWorkspace] launchApplication:
@"/Path/To/Main/App/Bundle"];

But if I try any NSWorkspace method to launch the application with the full path it fails, because Sandbox does not allow this.

If I try setting the argument of the above method to just my app name, it works, but launches, curiously, an older version of my app (I have these stored on my HDD, but they are not in the /Applications folder, only the correct version of my app is in the /Applications folder)

Does anybody now why this happens, or how could I fix this?

1

There are 1 answers

1
SarahR On BEST ANSWER

I found that the Helper app needs the path to the executable, not the path to the bundle.

So if you are giving it: /Applications/My Great App.app Try using: /Applications/MyGreatApp.app/Contents/MacOS/My Great App

And if your sandboxed app is not in the Applications folder, this will fail silently, while logging various permissions errors.