Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sandboxed app & NSOpenPanel causes crashes

I am doing a simple file open panel in my Cocoa app. I enable entitlements and app sandboxing. But on OS X 10.9, when the app should open a dialog using NSOpenPanel, it crashes with:

Application Specific Information:
Terminating app due to uncaught exception 'NSObjectNotAvailableException', reason: 'service com.apple.appkit.xpc.openAndSavePanelService failed to init an instance of NSOpenPanelService on behalf of due to { "proxy-communications-error" = "Error Domain=NSCocoaErrorDomain Code=4099 \"\U041d\U0435 \U0443\U0434\U0430\U043b\U043e\U0441\U044c \U0443\U0441\U0442\U0430\U043d\U043e\U0432\U0438\U0442\U044c \U0441\U0432\U044f\U0437\U044c \U0441 \U043f\U0440\U043e\U0433\U0440\U0430\U043c\U043c\U043e\U0439-\U043f\U043e\U043c\U043e\U0449\U043d\U0438\U043a\U043e\U043c.\" (The connection was invalidated from this process.) UserInfo=0x61000047dc00 {NSDebugDescription=The connection was invalidated from this process.}"; }'

Source:

self.panel = [NSOpenPanel openPanel];
panel.delegate = self;
panel.canChooseDirectories = YES;
panel.canChooseFiles = NO;
panel.canCreateDirectories = YES;
panel.allowsMultipleSelection = NO;
[self.panel beginSheetModalForWindow:contextWindow completionHandler:^(NSInteger returnCode) {
        ...
    }];

Has anyone seen this before?

like image 545
VKorsun Avatar asked Jul 29 '13 13:07

VKorsun


1 Answers

Indeed, you have to specifically allow Read/Write permissions on User Selected Files. In Xcode 5.1 this is under Capabilities - App Sandbox.

enter image description here

like image 171
Jay Versluis Avatar answered Sep 20 '22 21:09

Jay Versluis