【问题标题】:Using Cocoa NSSavePanel in Sandbox causes Assertion failure在 Sandbox 中使用 Cocoa NSSavePanel 会导致断言失败
【发布时间】:2018-06-05 20:52:20
【问题描述】:

我正在尝试使用 NSSavePanel 并将这一行添加到我的代码中。

let test = NSSavePanel()

每次调用此代码时都会出现此错误。 我不太确定这里发生了什么,因为我只是在创建一个新对象。 任何帮助表示赞赏。 谢谢!

*** 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
)

【问题讨论】:

    标签: swift xcode macos cocoa nssavepanel


    【解决方案1】:

    您对User Selected File 类型的File Access 权限可能仍设置为默认的Read Only

    1. 导航到目标的“功能”标签

    1. User Selected File 权限设置为Read/Write

    1. 运行您的应用(bridge absent 错误应该消失了)

    【讨论】:

    • 哇。为什么会这样/
    • 超级有帮助。谢谢@Jaysen Marais :)
    • @Rick 这与沙盒应用程序和 Mac App Store 的要求有关。您明确需要选择加入才能将内容保存在其他地方。
    • @Jaysen Marais 这救了我!
    • 令人惊讶的是,这条错误消息是多么无用,顺便说一句。您会认为苹果可能包含描述性错误消息,例如“权限错误”或其他内容。但是没有
    猜你喜欢
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    • 2011-05-02
    • 2017-06-18
    • 2013-08-17
    • 2020-06-04
    • 2018-09-05
    • 2013-08-25
    相关资源
    最近更新 更多