Error with initialise of persistent storage since 13.2 - The file “***” couldn’t be opened.

Hi,


we have app in store, that is frequenty updated and currently up to date - build with latest xCode againts latest SDK. However, there started to appear strange bug just after iOS 13.2. This bug never happens on older iOS.


We are using pretty standard function to initialize persistent storage:


        let storeDescription = NSPersistentStoreDescription()
        storeDescription.url = databaseDirectory.appendingPathComponent("\(modelName).sqlite")
        
        let container = NSPersistentContainer(name: modelName)
        container.persistentStoreDescriptions = [storeDescription]
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                 Check the error message to determine what the actual problem was.
                 */
                fatalError("Core Data initialization error \(error), \(error.userInfo)")
            }
        })
        return container


This code, that worked fine now fails to about 10% of customers - with:


crash_info_entry_0 Fatal error: Core Data initialization error: Error Domain=NSCocoaErrorDomain Code=256 "The file “GeotagPhotosProv4.sqlite” couldn’t be opened." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/644E2CAF-C5A9-4717-A9F3-080571F1FC00/Library/GeotagPhotosProv4.sqlite, NSSQLiteErrorDomain=23}


The strange is, that we were not able to reproduce this bug, it never happens to us on any of our devices. We tried clean install, start app from Apple Watch and all possible weird things, but no success.


Any idea, what could cause this? We are initializing persistent storage from application:didFinishLaunchingWithOptions: and it is called in the main thread.


Thanks,


Jindrich

Did you find a solution for this problem?
Hi, did you ever find a solution to this?

I can confirm this is still an issue as of October 2022

Still experiencing it as well. Has anyone found any root cause or/and fix for the problem?

Error with initialise of persistent storage since 13.2 - The file “***” couldn’t be opened.
 
 
Q