Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sandboxing, login items and launch App

Trying to make my app works with sandboxing I get stuck in this problem:

I need to add my App to login items so I've followed these steps:

  • Creating an HelperApp.app (with is agent = YES) that at the open exec this code :

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

    This app is sandboxed.

  • I added a copy build phase to my MyNewApp.app bundle with subpath Contents/Library/LoginItems and destination wrapper

    And obviously also the MyNewApp.app is sandboxed

  • In MyNewApp.app I registered with SMLoginItemSetEnabled the bundle id for the HelperApp.app

Now all works correctly but... when MyNewApp.app tries to launch MyNewApp.app I get an error:

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

But if I try to use the HelperApp.app to launch a not sandboxed (i.e. Steam.app) app it works like a charm!

Is there another way to launch the app? probably NSWorkSpace works with functions not allowed in sandbox context. What do you suggest?

like image 258
MatterGoal Avatar asked Jun 26 '12 17:06

MatterGoal


People also ask

What is app sandboxing and what is it for?

Android sandboxThe Android platform isolates apps from each other and protects them -- and the overall system -- from malicious apps and intruders. Android assigns a unique user ID (UID) to each application to create a kernel-level sandbox. This kernel ensures security between apps and the system at the process level.

Does Apple use sandboxing?

iOS and iPadOS help ensure runtime security by using a “sandbox,” declared entitlements, and Address Space Layout Randomization (ASLR).


1 Answers

You may want to have a look at my tutorial on how to get launch at login working in the sandbox.

like image 52
Tim Avatar answered Sep 28 '22 05:09

Tim