I'm working on an app that is using CoreData with Cloud Kit. I'm able to successfully perform CRUD operations on Entities in the app and I can see the data propagate up to iCloud. I also have an ObservableObject pattern set up so I see changes reflected in the UI when changes happen from other devices to the same data on all devices.
The problem is the use case of someone deleting the application, then re-installing it later. When I test this in Xcode, I can see the app (on first launch) start to sync data back to the app (via console messages from iCloud). But when I run a query and look at the NSFetchResults, I get a count = 0 on the entitiy records I'm looking for (even though they still persist in iCloud post app deletion).
I've tried everything from looking at NSPersistentHistoryChangeRequest in the AppDelegate hoping I would see activity, subscribing to the NSPersistentStoreRemoteChange notification in the content view, etc. While I do see transactions coming in via this method on initial app launch after a re-install (first run in Xcode), my local store still doesn't seem to reflect the new data when I query via the managedObjectContext.
What is the best practice to handle something like this? I've tried pulling apart the code sample from Apple from the WWDC 2019 sessions (Posts app), but as it's not in SwiftUI, some of the design patterns are different.
At this point I'm hoping for some better sessions on this at WWDC 2020 with SwiftUI but hoping someone may have dealt with this before and has a good solution.