Instead of the @objc
hack, the proper way to do it in Swift is to include the module name in NSExtensionPrincipalClass
, i.e.,
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ActionViewController</string>
(Documenting the error otherwise:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: ...)'
Hopefully will help someone who run into this error in the future.)
Xcode 15 shows an error that is verbose and more helpful:
__extensionPrincipalClass != nil - /Library/Caches/com.apple.xbs/Sources/ExtensionFoundation_Sim/ExtensionFoundation/Source/NSExtension/NSExtensionSupport/EXConcreteExtensionContextVendor.m:109:
Unable to find NSExtensionPrincipalClass (MessagesViewController) in
extension bundle! Please verify that the extension links the required
frameworks and that the value for NSExtensionPrincipalClass is
prefixed with '$(PRODUCT_MODULE_NAME).' if the class is implemented in
Swift. Type: Fault | Timestamp: 2023-09-19 18:05:10.722854-07:00 |
Library: ExtensionFoundation | Subsystem: com.apple.extensionkit |
Category: default | TID: 0x4f172