I'm trying to replicate the behavior of the iOS sample application provided by Apple in order to share my Core Data objects through CloudKit.
I am able to share CKRecords through Mail and Airdrop by obtaining the URL, but I cannot be able to get the iCloud Share modal window.
let sharingService = NSSharingService(named: .cloudSharing)
sharingService?.delegate = self
coredataContainer.share([ManagedObjectToShare], to: nil, completion: { [weak self] objectIDs, shareCK, container, error in
if let error = error {
fatalError(error.localizedDescription)
} else {
self?.sharingService?.perform(withItems: [shareCK?.url])
}
})
If I substitute the .cloudSharing
for .composeEmail
, the modal window opens correctly and provides me an URL to access to the object, but nothing happens when .cloudSharing
is seated as SharingService.
How can I accomplish this?