I'm trying to sandbox my app before submitting to the Mac App store and I need to open a dmg file. I tried the following, but I don't know if it's supposed to work with the 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 paste the full path into the terminal it work, if I run from the app 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.
The official word on NSTask and Sandboxing is 'some executables may work.' For me this translates to 'don't count on it'. Although this executable does seem to show the help menu correctly I do see sandboxing errors in Console.app that would make me wary.
I would agree with CodaFi on this one that you definitely shouldn't count on this to act how you'd like it to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With