0

I have an application that crashes with 'NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.' after a user upgrades from iOS6 to iOS7. The only fix for this is to delete the app because the persistent store is all messed up (obviously)

I really don't want users to have to delete the app and re-install it and lose all of their saved data. Is there a fix to help solve this issue?

rmaddy
  • 298,130
  • 40
  • 468
  • 517
JMD
  • 1,512
  • 2
  • 23
  • 52
  • What did you change in your last update with regards to CoreData? – coneybeare Jan 07 '14 at 20:06
  • I dont understand the question... the last update to coredata isn't really the problem. its upgrading from iOS6 to iOS7 – JMD Jan 07 '14 at 20:10
  • Is your persistent store stored in a place that is backed up across iOS updates? – coneybeare Jan 07 '14 at 20:12
  • its stored in the application's library directory – JMD Jan 07 '14 at 20:20
  • Have you tested using core data with the sqlite option set to JOURNAL=DELETE, this is the same mode that was used in iOS7. You should be able to duplicate the problem using the simulator by copying the sqlite file from the iOS6 simulator to the iOS7 simulator. If you are using iCloud then you won't be able to do this though. WAL mode never worked for me, it crashed in a number of different scenario so I always use journal mode now. – Duncan Groenewald Jan 07 '14 at 21:52
  • I'll look into this duncan. – JMD Jan 07 '14 at 21:56
  • I'm assuming you are using core data. Have you changed the name of your DB? Added fields to your datamodel? Have you looked at Apple's core data migration docs? https://developer.apple.com/library/ios/documentation/cocoa/conceptual/CoreDataVersioning/Articles/Introduction.html – Michael Jan 07 '14 at 20:07

2 Answers2

0

What is the crash? Showing the crash log will help.

I suspect you are hitting a migration issue but without that crash log it is going to be difficult to guess.

If you can create the crash state while running against Xcode, where does it crash?

What is the code point?

Is it at -addPersistentStore...? If so, what is the error being returned.

update

To be clear, if you are getting that generic error on a save that means you are ignoring the error on the -addPersistentStore call. Check that error and find out what the real problem is.

Marcus S. Zarra
  • 46,143
  • 9
  • 99
  • 181
  • The crash occurs on the first attempt at trying to save the managed object context – JMD Jan 07 '14 at 20:54
  • What is the crash?!? What line of code. Without these details you are not going to get an answer, you are going to get a guess. – Marcus S. Zarra Jan 08 '14 at 03:34
0

Can be that default journaling mode (WAL) is connected to data loss. CoreData turns on WAL by default since iOS 7. See Core Data and iOS 7: Different behavior of persistent store

Community
  • 1
  • 1
Ben Affleck
  • 11,374
  • 5
  • 50
  • 74
  • is this persistent store crash associated with data loss issues? they dont seem like they'd be the same. – JMD Jan 07 '14 at 20:59
  • @JMD you mentioned that you had iOS 6 -> 7 update, so I assumed that things might go wrong because CoreData defaults has changed in iOS 7. I am not exactly sure what happens if you open non-WAL sqlite db in WAL mode. – Ben Affleck Jan 07 '14 at 21:29
  • @Andy in theory you can open a non-WAL sqlite file in WAL mode but there have been quite a number of reported problems when using WAL mode, many of which have disappeared if journal model is used. – Duncan Groenewald Jan 07 '14 at 21:46
  • @DuncanGroenewald well, if app should work in both iOSes, worse if sqlite should be synchronized between devices over iCloud, I would stick to and enforce the same mode everywhere to avoid collisions. In this case old journaling mode. – Ben Affleck Jan 07 '14 at 21:56
  • @Andy yes I found the old mode works fine so always use it now. For a MAC desktop app WAL mode creates three files which is not a good UX so until NSPersistentDocument uses a package to provide a wrapper (or I create my own package wrapper) I'll have to stick with journal mode. – Duncan Groenewald Jan 07 '14 at 22:02