将产品模块名称添加到 FinderSync plist 中的 NSExtensionPrincipalClass 会导致崩溃

问题描述 投票:0回答:1

我的可可应用程序有一个查找器同步扩展。

按照 Apple 指南中的建议:https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html

我将 $(PRODUCT_MODULE_NAME) 添加到我的查找器的 info.plist 中。

这样做会导致取景器在到达初始点之前就崩溃了。

即使我的未捕获异常处理程序也无法捕获此异常。

我的扩展程序的 info.plist 文件。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>My App Finder Integration</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>XPC!</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSMinimumSystemVersion</key>
    <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
    <key>LSUIElement</key>
    <true/>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict/>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.FinderSync</string>
        <key>NSExtensionPrincipalClass</key>
        <string>$(PRODUCT_MODULE_NAME).FinderSync</string>
    </dict>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2017. All rights reserved.</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
    <key>NSSupportsAutomaticGraphicsSwitching</key>
    <true/>
</dict>
</plist>

错误堆栈跟踪是:

2017-05-25 14:53:52.231849 My App Finder Integration[6258:60938] [General] *** setObjectForKey: object cannot be nil (key: F376D0DD-5E4B-4E4F-9BAF-D685C62BE59D)
2017-05-25 14:53:52.232218 My App Finder Integration[6258:60938] [General] (
    0   CoreFoundation                      0x00007fffa968d0db __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffbe314a2a objc_exception_throw + 48
    2   CoreFoundation                      0x00007fffa958d115 -[__NSDictionaryM setObject:forKey:] + 1061
    3   Foundation                          0x00007fffab19a5a4 -[_NSExtensionContextVendor _setPrincipalObject:forUUID:] + 106
    4   Foundation                          0x00007fffab199d70 __105-[_NSExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 883
    5   libdispatch.dylib                   0x00007fffbebc8ef7 _dispatch_call_block_and_release + 12
    6   libdispatch.dylib                   0x00007fffbebc00b8 _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x00007fffbebcdb4b _dispatch_main_queue_callback_4CF + 925
    8   CoreFoundation                      0x00007fffa9643669 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    9   CoreFoundation                      0x00007fffa960465d __CFRunLoopRun + 2221
    10  CoreFoundation                      0x00007fffa9603b54 CFRunLoopRunSpecific + 420
    11  HIToolbox                           0x00007fffa8b8ea5c RunCurrentEventLoopInMode + 240
    12  HIToolbox                           0x00007fffa8b8e891 ReceiveNextEventCommon + 432
    13  HIToolbox                           0x00007fffa8b8e6c6 _BlockUntilNextEventMatchingListInModeWithFilter + 71
    14  AppKit                              0x00007fffa71345b4 _DPSNextEvent + 1120
    15  AppKit                              0x00007fffa78aed6b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
    16  AppKit                              0x00007fffa7128f35 -[NSApplication run] + 926
    17  AppKit                              0x00007fffa70f3850 NSApplicationMain + 1237
    18  libxpc.dylib                        0x00007fffbee5a8c7 _xpc_objc_main + 775
    19  libxpc.dylib                        0x00007fffbee592e4 xpc_main + 494
    20  Foundation                          0x00007fffab09415b +[NSXPCListener serviceListener] + 0
    21  PlugInKit                           0x00007fffb9feb41c -[PKService run] + 865
    22  PlugInKit                           0x00007fffb9feaf89 +[PKService main] + 55
    23  PlugInKit                           0x00007fffb9feb440 +[PKService _defaultRun:arguments:] + 17
    24  Foundation                          0x00007fffab2362bc NSExtensionMain + 51
    25  libdyld.dylib                       0x00007fffbebf6255 start + 1
    26  ???                                 0x0000000000000001 0x0 + 1
)
2017-05-25 14:53:52.232447 My App Finder Integration[6258:60938] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: F376D0DD-5E4B-4E4F-9BAF-D685C62BE59D)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffa968d0db __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffbe314a2a objc_exception_throw + 48
    2   CoreFoundation                      0x00007fffa958d115 -[__NSDictionaryM setObject:forKey:] + 1061
    3   Foundation                          0x00007fffab19a5a4 -[_NSExtensionContextVendor _setPrincipalObject:forUUID:] + 106
    4   Foundation                          0x00007fffab199d70 __105-[_NSExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 883
    5   libdispatch.dylib                   0x00007fffbebc8ef7 _dispatch_call_block_and_release + 12
    6   libdispatch.dylib                   0x00007fffbebc00b8 _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x00007fffbebcdb4b _dispatch_main_queue_callback_4CF + 925
    8   CoreFoundation                      0x00007fffa9643669 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    9   CoreFoundation                      0x00007fffa960465d __CFRunLoopRun + 2221
    10  CoreFoundation                      0x00007fffa9603b54 CFRunLoopRunSpecific + 420
    11  HIToolbox                           0x00007fffa8b8ea5c RunCurrentEventLoopInMode + 240
    12  HIToolbox                           0x00007fffa8b8e891 ReceiveNextEventCommon + 432
    13  HIToolbox                           0x00007fffa8b8e6c6 _BlockUntilNextEventMatchingListInModeWithFilter + 71
    14  AppKit                              0x00007fffa71345b4 _DPSNextEvent + 1120
    15  AppKit                              0x00007fffa78aed6b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
    16  AppKit                              0x00007fffa7128f35 -[NSApplication run] + 926
    17  AppKit                              0x00007fffa70f3850 NSApplicationMain + 1237
    18  libxpc.dylib                        0x00007fffbee5a8c7 _xpc_objc_main + 775
    19  libxpc.dylib                        0x00007fffbee592e4 xpc_main + 494
    20  Foundation                          0x00007fffab09415b +[NSXPCListener serviceListener] + 0
    21  PlugInKit                           0x00007fffb9feb41c -[PKService run] + 865
    22  PlugInKit                           0x00007fffb9feaf89 +[PKService main] + 55
    23  PlugInKit                           0x00007fffb9feb440 +[PKService _defaultRun:arguments:] + 17
    24  Foundation                          0x00007fffab2362bc NSExtensionMain + 51
    25  libdyld.dylib                       0x00007fffbebf6255 start + 1
    26  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
objective-c xcode cocoa findersync
1个回答
0
投票

当您使用没有该格式的 Swift 类时,Xcode 15 会显示错误,这与您的场景相反......但错误显示:

__extensionPrincipalClass != nil - /Library/Caches/com.apple.xbs/Sources/ExtensionFoundation_Sim/ExtensionFoundation/Source/NSExtension/NSExtensionSupport/EXConcreteExtensionContextVendor.m:109:无法在扩展包中找到 NSExtensionPrincipalClass (MessagesViewController)! 请验证扩展是否链接所需的框架,并且 NSExtensionPrincipalClass 的值是否以“$(PRODUCT_MODULE_NAME)”为前缀。如果该类是在 Swift 中实现的。 类型: 故障 |时间戳: 2023-09-19 18:05:10.722854-07:00 |图书馆:ExtensionFoundation |子系统:com.apple.extensionkit |类别: 默认 | TID:0x4f172

(强调我的)

所以我认为对于 O-C,你可能只需要输入类名即可。

© www.soinside.com 2019 - 2024. All rights reserved.