2012-02-02 61 views
6

我正在嘗試在提交到Mac App Store之前對我的應用程序進行沙盒處理,並且需要打開一個dmg文件。我嘗試了以下方法,但我不知道它是否應該與Apple Sandbox一起使用。Sandbox和NSTask

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]; 

如果我貼的完整路徑到終端的IT工作,如果我從應用程序,我碰到下面的錯誤運行:

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. 

感謝您的幫助! S.

+0

您無法安裝沙盒DMG,這是不安全的。 – CodaFi 2013-05-26 07:44:26

+0

我有完全相同的問題。只是想知道@ user375584是否已修復它。謝謝 – Josh 2015-02-18 18:12:00

回答

0

NSTask和Sandboxing的官方文字是'一些可執行文件可能有效。'對我來說,這意味着'不要指望它'。雖然這個可執行文件似乎正確地顯示了幫助菜單,但我確實在Console.app中看到了沙箱錯誤,這會讓我很擔心。 Screenshot

我會同意CodaFi這一個,你絕對不應該指望這個行爲如何你喜歡它。