watchOS 10: CloudKit CoreData Sync (NSPersistentCloudKitContainer) Requires Watch on Charger

I've encountered a significant sync issue with watchOS 10 RC on every device combination I've tested, running both iOS 17 and watchOS 10. I'm curious if others have noticed a similar problem.

Context:

  • Standalone watchOS app developed in SwiftUI with a companion iOS app.
  • Both apps use NSPersistentCloudKitContainer for bi-directional CloudKit CoreData Sync between the iOS app and watch.
  • Previously, this sync mechanism was near instant in the foreground and took max 1-2 minutes in the background
  • NSPersistentCloudKitContainer has been reliable since the app was first developed in the watchOS 6/iOS 13 era.

Issue:

  • In watchOS 10 RC, sync can take hours--and doesn't even occur when the app is in the foreground.
  • Sync only reliably happens when the watch is placed on the charger, seemingly only if the charge is over 50%.
  • Once taken off the charger, the watch will continue push and receive CoreData changes briefly before becoming unresponsive to sync again.

Additional Info:

  • The problem persists even when recompiled with the latest Xcode RC.
  • It's problem is consistent in both production and development CloudKit environments.
  • The CloudKit log shows no watch activity upon CoreData object updates, until placed on the charger (with over 50% charge). The sync starts in the background while the watch is charging.
  • The iOS app, however, reflects immediate activity in the CloudKit log after a CoreData change from the device and reacts promptly to pushes when they eventually occur from the watch.
  • The NSPersistentCloudKitContainer code hasn't changed since it was implemented.
  • Background modes for remote notifications are set correctly, and when sync finally happens, it's accurate.

I'm stumped. Perhaps there's a new watchOS 10 setting affecting CloudKit sync QoS? Or could this be a known watchOS 10 RC bug?

Please file a Feedback (https://developer.apple.com/bug-reporting/) and link it here, including a sysdiagnose covering your reproduction with CloudKit logging enabled (https://developer.apple.com/bug-reporting/profiles-and-logs/?name=cloudkit). That will hopefully allow us to understand the root cause of the symptoms you see. Thank you!

Thanks. I filed a Feedback earlier (FB13183124) and submitted a sysdiagnose with the CloudKit profile installed.

Were you able to resolve the issue? I'm experiencing similar behaviour running the release version of watchOS 10 (and 10.0.1).

I am having the same experience in my product environment. I am getting complaints from users of my application.

What are your logs showing? I'm having issues as well on both iOS 17 and watchOS 10. The most interesting part is this:

("CoreData: CloudKit Setup"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

Also, do you see your app contacting iCloud servers in app privacy report?

I have been able to fix iCloud CoreData sync by migrating my watch app from an extension to a single app using the upgrade process offered by Xcode. While CoreData CloudKit syncing is now working correctly, the migration has created a separate issue with CoreLocation as highlighted in another forum discussion:

https://developer.apple.com/forums/thread/736785

Thanks for the update. Can you please indicate where in Xcode to find the process you mentioned (to upgrade a watch app from an extension to a single app)?

I believe you'll find this option in the issue navigator, but I cannot remember if that's the spot. Assuming your project fits what Xcode is looking for, Xcode should provide you with the option to merge your watchOS App Target and Extension Target targets into a single target.

Select the project file in Xcode 15, select the [Editor] menu, select [Validate Settings], then a check box will appear prompting to migrate to a single app. This method improved the issue, but I would like an official statement from Apple as to whether the old extension format apps are no longer supported.

Thanks for the details, I see the option there. I have the same concern about whether the old extension format apps re no longer supported. Apple documentation doesn't appear to have been updated for Xcode 15 in regards to creating a phone app with a companion watch app. The steps involved in are quite different and, from what I can see, such apps are now created with a single watch app target.

And forgive me if this question is slightly off topic, but has anyone else also seen their watch apps being inexplicably terminated?

I finally got to the point where I used Xcodes's process to upgrade my app from an extension to a single app. Once I did, the app crashes during the launch process with a signal SIGABRT error pointing to : class ApplicationDelegate: NSObject, WKApplicationFelegate (I renamed the class from ExtensionDelegate) with no indication of it having been a particular line of code that led to it. Just a general question, were there any other obvious changes that needed to be made for this to work?

For anyone else running into this issue, in my case at least (developed in Swift and using storyboard), after using the Xcode tool to migrate to a single app, I needed to go into the storyboard and change the Module for every interface controller and row controller I had created. These still specified the watch app extension rather than the watch app.

watchOS 10: CloudKit CoreData Sync (NSPersistentCloudKitContainer) Requires Watch on Charger
 
 
Q