Crash on iOS9 with -[NSPersistentStoreCoordinator _coordinator_you_never_successfully_opened_the_database_device_locked:]

Hi,


My app have recently been getting these crashes from crashlytics that is only happening on iOS9 and strangely only on iPhone 6S devices so far

Fatal Exception: NSInternalInconsistencyException
This NSPersistentStoreCoordinator has no persistent stores (corrupt file). It cannot perform a save operation.

The last call from the report is


-[NSPersistentStoreCoordinator _coordinator_you_never_successfully_opened_the_database_device_locked:]


Anybody know what could be causing these crashes?

Answered by NotMyName in 78280022

The cause is in the descriptor: Your application tried to open the open the persistent store while the device was locked, and your code tripped over the data protection API.


That's the sort of thing that you trip over on new devices and new iOS versions because the new device is fast enough to get your app running before the data protection code is done with the transition.

Accepted Answer

The cause is in the descriptor: Your application tried to open the open the persistent store while the device was locked, and your code tripped over the data protection API.


That's the sort of thing that you trip over on new devices and new iOS versions because the new device is fast enough to get your app running before the data protection code is done with the transition.

I see, that makes sense, and it explains why it's only happening on 6S and 6S plus. but just out of curiosity, can you tell me more about this data protection API and how does it work? just so I dont trip over it anymore in the future. Thank you.

I am seeing the same thing and mostly on iPhone 6s devices. Is there anything I can do to protect the app from this crash?

You pretty much have to go into your start up code, and rewrite it so that it checks to see if protected data is available, and then delaying your Core Data start up until

applicationProtectedDataDidBecomeAvailable.


I'm not familiar enough with the current Core Data templates in Xcode to know whether they currently demonstrate how to do that well, yet.

Crash on iOS9 with -[NSPersistentStoreCoordinator _coordinator_you_never_successfully_opened_the_database_device_locked:]
 
 
Q