UICloudSharingController sharing via Messages broken in iOS16

In the summer, Apple published an informative sample app on sharing objects between iCloud users using Core Data, CloudKit and UICloudSharingController in SwiftUI: https://developer.apple.com/documentation/coredata/sharing_core_data_objects_between_icloud_users

However, Apple also announced the new Collaboration features for Messages in iOS16.

Now, it seems Collaboration is incompatible with UICloudSharingController and the sharing sheet it invokes, on iOS16.

MRE: See the Apple sample app linked above.

Reproduction:

  1. Create new share,
  2. Manage share with UICloudSharingController,
  3. Share With More People,
  4. Share using Messages (may succeed first time but fails on subsequent attempts on iOS16. Works great on iOS15).

Expectation: We can use UICloudSharingController to add new participants, using Messages, Mail or other platforms. The link will display correctly on all devices.

Reality: On iOS16+, attempting to share via Messages engages the "Collaboration" framework and leads to an alert: "An Error Occurred. Unable to start collaboration" (see Image 1). Triggering this error breaks ANY further shares - the link now cannot be created for Mail and other platforms either (see Image 2). Furthermore, if the first attempt succeeds, the link does not appear correctly on the receiving device (see Image 3). The link appears correctly when sent from a device running iOS15.

Question: How can this be resolved, so that we can share CloudKit records between users using Messages in iOS16+?

Images: https://imgur.com/a/o1fdABT

  • please file a bug report in the Feedback Assistant app.

  • Submitted as FB11623246

Add a Comment

Accepted Reply

As of iOS 16.0.3, this issue appears to have gone away when using the Apple sample app. I am still using the same downloaded code, so a fix was possibly made by Apple on CloudKit side of things.

After investigating, I still encountered the issue when invoking UICloudSharingController using UIViewControllerRepresentable (like in the RayW sample code).

The issue does not appear (anymore) when invoking UICloudSharingController using UIViewController (like in the Apple sample code).

  • I'm using Apple's sample code from here (https://developer.apple.com/documentation/coredata/sharing_core_data_objects_between_icloud_users) on iOS 16.0.3 and I still see the same problem. Once the object is shared, the UICloudSharingController works fine. But if you stop sharing and try sharing again, it doesn't work anymore, the message is a spinner that spins indefinitely regardless if I'm invoking from UIViewController or not.

  • I spoke too soon. The issue started appearing again. It does not matter whether UICloudSharingController is invoked using UIViewController or UIViewControllerRepresentable. It looks like I cannot remove the "solved" badge from this comment, so I guess I will create a new post.

Add a Comment

Replies

On further inspection, the following console message appears when this issue happens for the first time:

CoreDataCloudKitShare[3672:1242159] systemSharingUIDidSaveShareBlock received error: <CKError 0x28314d8c0: "Server Record Changed" (14/2004); server message = "client oplock error updating record"; op = 134D57570A63DF3A; uuid = 8F070F8B-0AC0-4FFE-A52D-154BCBF3196C; container ID = “containerID>

Where containerID is the CKContainer ID, like “iCloud.com.company.samples.CoreDataCloudKitShare”. The message does not appear on subsequent attempts to add more people.

On further inspection, the same problem also manifests in other samples which use CoreData+CloudKit sharing, for example: https://www.raywenderlich.com/29934862-sharing-core-data-with-cloudkit-in-swiftui

The problem does NOT appear in samples that use pure CloudKit, such as: https://github.com/apple/sample-cloudkit-sharing

This leads me to suppose there is something weird going on between Core Data and UICloudSharingController.

A bug report was submitted as FB11623246

I am also experiencing the exact same problem

As of iOS 16.0.3, this issue appears to have gone away when using the Apple sample app. I am still using the same downloaded code, so a fix was possibly made by Apple on CloudKit side of things.

After investigating, I still encountered the issue when invoking UICloudSharingController using UIViewControllerRepresentable (like in the RayW sample code).

The issue does not appear (anymore) when invoking UICloudSharingController using UIViewController (like in the Apple sample code).

  • I'm using Apple's sample code from here (https://developer.apple.com/documentation/coredata/sharing_core_data_objects_between_icloud_users) on iOS 16.0.3 and I still see the same problem. Once the object is shared, the UICloudSharingController works fine. But if you stop sharing and try sharing again, it doesn't work anymore, the message is a spinner that spins indefinitely regardless if I'm invoking from UIViewController or not.

  • I spoke too soon. The issue started appearing again. It does not matter whether UICloudSharingController is invoked using UIViewController or UIViewControllerRepresentable. It looks like I cannot remove the "solved" badge from this comment, so I guess I will create a new post.

Add a Comment

Were you able to make it work? I'm facing similar issue with Apple Mail app. I'm getting the prompt that I've attached and the log says "systemSharingUIDidSaveShareBlock received error: <CKError 0x2801d9500: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; op = 33F7539C6A16E928; uuid = DF53ACF4-73AE-4763-947E-2A3FA7E4F241; container ID = "iCloud.my.container.id">". This only happens with Apple mail. other options like Messages, Gmail and Link sharing "Invite with link" work. Sharing with Apple mail stopped working after upgrading to iOS 16.

  • It could be related. I opened a DTS and Apple confirmed my issue as a known bug with high priority. In your case, the console output could be informative - you should double-check that your bundle ID is set correctly throughout the app.

  • Bundle Id is set correctly. I had no issues before iOS 16 / iPadOS 16. I also tried apple's sample code for CloudKit Sharing and that's also not working with Apple Mail.

  • Check out SWCollaborationView. It's not working for me because it does not appear to be compatible with SwiftUI. But if you're using UIKit, SWCollaborationView can replace UICloudSharingCntroller. I can confirm the share goes through even on subsequent attempts.

This is now confirmed by Apple as a known bug with high priority. A detailed, up-to-date post is kept at SO: https://stackoverflow.com/questions/73888519/uicloudsharingcontroller-does-not-work-for-core-data-with-cloudkit