Sandbox, Login Elements, and Application Launch

Trying to get my application to work with the sandbox, I am stuck in this problem:

I need to add my application to the login elements, so I followed these steps:

  • Creating HelperApp.app (c is agent = YES), which, when opened, executes this code:

    NSString * appPath = @ "/Applications/MyNewApp.app"; [[NSWorkspace sharedWorkspace] launchApplication: appPath]; [NSApp terminate: nil];

    This app is isolated.

  • I added the copy build phase to my MyNewApp.app package with submission Contents/Library/LoginItemsand destinationwrapper

    And obviously MyNewApp.app is sandboxed

  • In MyNewApp.app I registered in SMLoginItemSetEnabledthe package identifier for HelperApp.app

Now everything works correctly, but ... when MyNewApp.app tries to start MyNewApp.app I get an error message:

LSOpenFromURLSpec() returned -10827 for application /Applications/MyNewApp.app path (null).

But if I try to use HelperApp.app to launch an application without a sandbox (for example, Steam.app), it works like a charm!

Is there any other way to run the application? NSWorkSpace probably works with features not allowed in the sandbox context. What do you suggest?

+5
source share
1 answer
+4
source

All Articles