We're doing a custom collaboration and trying to follow the example code in the presentation "Integrate your custom collaboration app with Messages".
This issue is happening on iOS 16 beta 4.
After creating and setting up a SWCollaborationMetadata object, we're creating an NSItemProvider and registering the metadata object. The call to registerObject() is crashing with the exception:
+[_SWCollaborationMetadata writableTypeIdentifiersForItemProvider]: unrecognized selector sent to class 0x1ea29aed0
It seems like the SWCollaborationMetadata is maybe not actually compliant to the NSItemProviderWriting protocol, despite the fact that it is documented to be so. In fact, looking at the header `SWCollaborationMetadata.h, it looks like it does not comply with NSItemProviderWriting after all:
@interface SWCollaborationMetadata : NSObject <NSSecureCoding, NSCopying, NSMutableCopying>
...which of course would explain the crash.
I've set up a sample project which contains basically identical code to what is shown in the WWDC session, and still getting this issue. I have added the SharedWithYou entitlement. Is this a known issue in the current betas, or is there some updated sample code somewhere.
Here's the function I'm testing it with:
func share() {
let localIdentifier = SWLocalCollaborationIdentifier(rawValue: "identifier")
let metadata = SWCollaborationMetadata(localIdentifier: localIdentifier)
metadata.title = "Content Title"
metadata.initiatorHandle = "user@example.com"
let formatter = PersonNameComponentsFormatter()
if let components = formatter.personNameComponents(from: "Devin") {
metadata.initiatorNameComponents = components
}
let itemProvider = NSItemProvider()
itemProvider.registerObject(metadata, visibility: .all)
let activityConfig = UIActivityItemsConfiguration(itemProviders: [itemProvider])
let shareSheet = UIActivityViewController(activityItemsConfiguration: activityConfig)
self.present(shareSheet, animated: true)
}
The crash happens at the call to itemProvider.registerObject(metadata, visibility: .all)
Thanks, Adam