I have an application Main.app and an application Helper.app within the Main.app/Library/LoginItems folder. The Main.app can be started by the user, and the user can then set Helper.app as login item. (using SMLoginItemSetEnabled()), this works perfectly. When the user sets the Helper.app as login item it is also launched.
However, it should also be possible to launch the Helper.app without setting it as a login item. I've tried to do this with
[[NSWorkspace sharedWorkspace] launchApplication: newPath];
which gives a lsboxd: Not allowing process to launch... error, and with
[NSTask launchedTaskWithLaunchPath:newPath arguments: [NSArray array]];
wich gives a deny forbidden-sandbox-reinit error. (presumably because the Helper.app is inside Main.app?)
newPath is found as follows:
NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:[[[NSBundle mainBundle] bundlePath] pathComponents]];
[pathComponents addObject:@"Contents"];
[pathComponents addObject:@"Library"];
[pathComponents addObject:@"LoginItems"];
[pathComponents addObject:@"Helper.app"];
[pathComponents addObject:@"Contents"];
[pathComponents addObject:@"MacOS"];
[pathComponents addObject:@"Helper"];
NSString *newPath = [NSString pathWithComponents:pathComponents];
How can i fix this? :)
Thanks,