I have an existing iOS/watchOS app that uses a third-party database and WatchConnectivity. For various reasons I am migrating the app to use Core Data with CloudKit.
I have everything working using NSPersistentCloudKitContainer
. Sync between the iOS and watchOS app are working on my test devices when I start with an empty database.
However, I need to import existing user's data when they first install this new version. Some users may have hundreds or thousands of records, but the total database size is under 1-2MB.
Data migration/import is working on the iOS side, the Core Data entities are populated on first launch and uploaded to CloudKit (I see in the debug logs that a NSPersistentCloudKitContainer.Event
export
ends successfully).
The problem is launching the watchOS app does not sync the data from CloudKit. I see a import started
event but never see it end. I never see any Core Data entities appear on watchOS even after waiting several minutes and re-opening the Watch app multiple times. New entities or modifications made on either app are also not synced.
Is the problem just too much data which causes the CloudKit sync to never finish?
What are the best practice to populate a watchOS app with initial data from the parent iOS app and keep it in sync with CoreData/CloudKit?