How to solve Core Data Crash?

Viewed 406

I am using Coredata in my iOS app. Let me explain my problem.

  1. I had used Core data in my app and uploaded the same on App Store with version V1.

  2. After some days, I need some additional functionality. I updated my old Data model Schema and added an attribute (My mistake as I had to do lightweight migration). I uploaded the app on Appstore with version V2

  3. Suddenly App started crashing for many users (This NSPersistentStoreCoordinator has no persistent stores (schema mismatch or migration failure). It cannot perform a save operation. -[NSPersistentStoreCoordinator _exceptionNoStoreSaveFailureForError:recommendedFrame:]). I immediately realized my mistake. I tried to reproduce the Scanio multiple times (updating the new app over the old app), But I am not able to reproduce the crash even a single Time. I don't know why only some of the users are facing this crash.

Now I need a solution to resolve this issue. I need to upload a new App version V3 that should work fine for all users whether they are coming from V1 or V2.

One solution is I make an exact copy of Core data from V2, Then migrate the Core data to a new version and upload the same to the App store. I assume this solution will work for users coming from V2, but will this work for users coming from V1 as Old Core data Schema is not the same in V1 and V3?

2nd Solution is that I make an exact copy of Core data from V1, Then migrate the Core data to the new version. Add the new attribute that I have added in V2 and upload the same to the App store. I assume this solution will work for users coming from V1, but will this work for users coming from V2 as Old Core data Schema is not the same in V2 and V3?

Also Can anyone explain why the crashes are occurring for some users only?

0 Answers
Related