Sandbox and NSTask

I am trying to isolate my application before sending it to the Mac App repository and I need to open the dmg file. I tried the following, but I do not know if it should work with Apple Sandbox.

NSTask *task = [[NSTask alloc] init]; [task setLaunchPath: @"/usr/bin/hdiutil"]; [task setArguments: [NSArray arrayWithObjects: @"attach", [NSString stringWithFormat:@"%@/myfile.dmg", documentsDirectory], nil]]; [task launch]; [task waitUntilExit]; if (0 != [task terminationStatus]) NSLog(@"Mount failed."); [task release]; 

If I insert the full path into the terminal, it works, if I run the application, I get the following error:

 diskimages-helper[11437:303] ERROR: couldn't connect to framework. diskimages-helper[11437:303] DIHelper: setupConnectionToFrameworkWithUUID: failed hdiutil: attach failed - No child processes Mount failed. 

Thanks for any help! S.

+6
source share
1 answer

The official word in NSTask and Sandboxing is "some executables may work." For me, it means "don't count on it." Although this executable seems to display the help menu correctly, I see sandbox errors in Console.app, which would make me wary. Screen shot

I agree with CodaFi that you should definitely not count on it to act the way you would like.

0
source

Source: https://habr.com/ru/post/907516/


All Articles