My cocoa application has a finder sync extension.
As suggested in the Apple guide: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html
I added $(PRODUCT_MODULE_NAME) to my finder's info.plist.
Doing this has caused the finder to crash even before it hits the init point.
Even my uncaught exception handler isn't able to catch this exception.
My extension's info.plist file.
<?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>
The error stack trace is:
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
来源:https://stackoverflow.com/questions/44117848/adding-product-module-name-to-nsextensionprincipalclass-in-findersync-plist-cras