Reputation: 399
I wrote a Mac app that turns Desktop icons visible/invisible. I use NSTask
to run a terminal command to reset the Finder
:
- (void)killFinder
{
NSTask *killFinderTask = [[NSTask alloc]init];
NSArray *killFinderArray = [NSArray arrayWithObjects:@"Finder", nil];
[killFinderTask setLaunchPath:@"/usr/bin/killall"];
[killFinderTask setArguments:killFinderArray];
[killFinderTask launch];
[killFinderTask waitUntilExit];
}
Before turning on Sandboxing, it runs alright. When I turn on Sandboxing, a message in console said:
killall: warning: kill -TERM 46676: Operation not permitted
My app still runs but the result is not correct. The part which reset the Finder
is not run. How do I circumvent this issue so that I can still use Sandboxing but the task is still run?
Upvotes: 2
Views: 2253
Reputation: 34983
Use NSUserScriptTask
to run the Script.
The script file must be placed (by the user) in the NSApplicationScriptsDirectory
to be run outside of the Sandbox.
Upvotes: 1