I am having a hard time debugging an issue with NSTask.
I start NSTask using the following:
NSTask *convTask = [[NSTask alloc] init];
[convTask setLaunchPath:[[NSBundle mainBundle] executablePath]];
[convTask setArguments: [NSArray arrayWithObjects: @"convTask", source, target, nil]];
[convTask launch];
[convTask waitUntilExit];
[convTask terminate];
So it is basically launching a task that is another instance of my running app. This task is supposed to convert source (a file) to target (another file). And that is not working only when activate Sandbox. But even in Sandbox mode, when I use my terminal to execute the app using the same parameter passed to NSTask then the target gets created.
Thanks for your help!
According to the Entitlement Key Reference:
If your app employs a child process created with either the posix_spawn function or the NSTask class, you can configure the child process to inherit the sandbox of its parent.
and:
To enable sandbox inheritance, a child target must use exactly two App Sandbox entitlement keys: com.apple.security.app-sandbox and com.apple.security.inherit. If you specify any other App Sandbox entitlement, the system aborts the child process.
I suspect that forking yourself won't be a successful strategy, since that would mean the parent has to have only those two entitlements, which wouldn't be very useful in the child process.