Thank you very much for your answer Ziqiao!
I have a better understanding of the logic behind the error.
And yes I do have widgets! So this seems to be the best lead. I have added additional logging, hoping to confirm this theory. But it will take time and effort to be 100% sure.
Meanwhile, let's say this is really the culprit, how do you officially approach this issue?
I can think of these 2 potential solutions:
Is there a way to "detect and wait" for a migration to be done? So that when the widget (or the main app) initializes the shared CoreData stack, I first check if a migration is ongoing and retry to open later?
Do you recommend avoiding sharing the same CoreData stack between the main app and the widget? So I should create a separate CoreData file exclusive to widgets?
I can even think of a third solution which is close to manually doing solution 1. I create my own set of flags lastMigrationVersion and lastMigrationDate.
If I see that a stack (let's say the main app one) did trigger a lightweight migration, I can check if enough time was given for the migration before attempting to open the stack from elsewhere (let's say from the widget). But it means hardcoding a static delay of... let's imagine 1.5 second before opening a potentially migrating CoreData stack. I have no idea how long a migration can last unfortunately but I take that 1 second should be enough in the majority of cases? It's not a stable solution...
What do you recommend?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: