Sandbox Autolaunch

  • I'm having the very devil of a time trying to get auto launch of sandboxed apps to work, which is a real pity because I can think of quite a few apps for which it would be rather handy.  My latest attempt flings out the following error:

    13/05/2013 21:42:09.962 com.apple.AppSandboxSMLoginItemEnabler[2112]: Attempt to enable file://localhost/Applications/DeviceInfo.app/Contents/Library/LoginItems/DeviceInfoLoginHelperApp.app/ without sandbox from sandboxed app

    In this incarnation, I've signed and archived the helper app separately from the main application that I'm trying to launch.  This is really messing with my mind - is anyone able to suggest what I'm doing wrong?

    The login helper App is included in the main app, and the code in the main app seems to function correctly:

    - (IBAction)autoLaunchChange:(id)sender
    {

    // Creating helper app complete URL
    NSURL *url = [[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]] URLByAppendingPathComponent:@"Contents/Library/LoginItems/DeviceInfoLoginHelperApp.app"];


    // Registering helper app
    if (LSRegisterURL((__bridge CFURLRef)url, true) != noErr)
    {
    NSLog(@"LSRegisterURL failed!");
    }


    if (!SMLoginItemSetEnabled ((CFStringRef)@"com.PaxSoftware.DeviceInfoLoginHelperApp", ([autoLaunch state]==NSOnState)))
        {
            [
    autoLaunch setState:NSOffState];
            NSAlert *alert = [NSAlert alertWithMessageText:@"An error occurred"
                                            defaultButton:@"OK"
                                          alternateButton:nil
                                              otherButton:nil

    informativeTextWithFormat:@"Couldn't set DeviceInfo Launch State."];
            [alert runModal];
        }

    }

    The login helper App has the following code (although this code never executes - so this particular problem isn't here!):

    - (
    void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {

    NSLog(@"Attempting Magic");



        BOOL alreadyRunning = NO;
        BOOL isActive = NO;

    NSArray *running = [[NSWorkspace sharedWorkspace] runningApplications];
        for (NSRunningApplication *app in running)
        {

    if ([[app bundleIdentifier] isEqualToString:@"com.PaxSoftware.DeviceInfo"])
            {
                alreadyRunning = YES;
                isActive = [app isActive];
            }
        }


    NSLog(@"alreadyRunning %d  isActive %d ",alreadyRunning,isActive);


        if (!alreadyRunning || !isActive)
        {
            NSString *path = [[NSBundle mainBundle] bundlePath];
            NSArray *p = [path pathComponents];
            NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:p];
            [pathComponents removeLastObject];
            [pathComponents removeLastObject];
            [pathComponents removeLastObject];
            [pathComponents addObject:@"MacOS"];
            [pathComponents
    addObject:@"DeviceInfo"];
            NSString *newPath = [NSString pathWithComponents:pathComponents];

            NSLog(@"%@",newPath);

            [[
    NSWorkspace sharedWorkspace] launchApplication:newPath];
        }
        [NSApp terminate:nil];
    }
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today