Using Cocoa NSSavePanel in Sandbox causes Assertion failure

橙三吉。 提交于 2019-12-20 17:18:54

问题


I'm trying to use the NSSavePanel and added this line to my code.

let test = NSSavePanel()

Everytime this code is called the this error appears. I'm not quite sure what is happening here because I'm only creating a new object. Any help appreciated. Thanks!

*** Assertion failure in -[NSVBSavePanel viewWillInvalidate:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.20.106/Nav.subproj/OpenAndSavePanelRemote/NSVBOpenAndSavePanels.m:387
2017-12-23 18:11:33.110099+0100 test[27753:1527254] -[NSVBSavePanel init] caught non-fatal NSInternalInconsistencyException 'bridge absent' with backtrace (
    0   CoreFoundation                      0x00007fff3ca1900b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fff635f7c76 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3ca1eda2 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fff3eb2b260 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
    4   AppKit                              0x00007fff3a1e748e -[NSVBSavePanel viewWillInvalidate:] + 188
    5   ViewBridge                          0x00007fff60f376f2 -[NSRemoteView invalidate:] + 292
    6   ViewBridge                          0x00007fff60f44e88 -[NSRemoteView _advanceToConfigPhaseLegacy] + 1111
    7   ViewBridge                          0x00007fff60f45d1b -[NSRemoteView _viewServiceMarshalProxy:withDetailedErrorHandler:] + 230
    8   ViewBridge                          0x00007fff60f46104 -[NSRemoteView _viewServiceMarshalProxy:withErrorHandler:] + 78
    9   ViewBridge                          0x00007fff60f38194 -[NSRemoteView bridge] + 227
    10  AppKit                              0x00007fff3a1a2e36 -[NSVBSavePanel init] + 292
    11  AppKit                              0x00007fff3a66fc7e -[NSSavePanel initWithContentRect:styleMask:backing:defer:] + 71
    12  AppKit                              0x00007fff3a1a3093 -[NSPanel init] + 87
    13  test                                0x0000000100002933 _T0So11NSSavePanelCABycfcTO + 19
    14  test                                0x000000010000131c _T0So11NSSavePanelCABycfC + 60
    15  test                                0x0000000100001285 _T04test14ViewControllerC11viewDidLoadyyF + 85
    16  test                                0x00000001000013b4 _T04test14ViewControllerC11viewDidLoadyyFTo + 36
    17  AppKit                              0x00007fff39fc1632 -[NSViewController _sendViewDidLoad] + 97
    18  AppKit                              0x00007fff39fb806d -[NSViewController _loadViewIfRequired] + 390
    19  AppKit                              0x00007fff39fb7e9d -[NSViewController view] + 30
    20  AppKit                              0x00007fff3a13675d -[NSWindow _contentViewControllerChanged] + 109
    21  Foundation                          0x00007fff3ea99ade -[NSObject(NSKeyValueCoding) setValue:forKey:] + 331
    22  AppKit                              0x00007fff3a1794b1 -[NSWindow setValue:forKey:] + 111
    23  AppKit                              0x00007fff3a179415 -[NSIBUserDefinedRuntimeAttributesConnector establishConnection] + 637
    24  AppKit                              0x00007fff39f45bbd -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1430
    25  AppKit                              0x00007fff3a04113a -[NSNib _instantiateNibWithExternalNameTable:options:] + 679
    26  AppKit                              0x00007fff3a040d96 -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 136
    27  AppKit                              0x00007fff3a797180 -[NSStoryboard instantiateControllerWithIdentifier:] + 236
    28  AppKit                              0x00007fff39f39ecf NSApplicationMain + 729
    29  test                                0x0000000100002d0d main + 13
    30  libdyld.dylib                       0x00007fff641e7115 start + 1
)

回答1:


Your File Access permissions for the User Selected File type are probably still set to the default Read Only value

  1. Navigate to the 'Capabilities' tab for your target

  1. Set the User Selected File permission to Read/Write

  1. Run your app (the bridge absent error should be gone)


来源:https://stackoverflow.com/questions/47954418/using-cocoa-nssavepanel-in-sandbox-causes-assertion-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!