我的可可应用程序有一个查找器同步扩展。
正如苹果指南中所建议的那样: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