4

I am getting the next error in the Crashlytics reporting tool:

Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=256 "The file “xxxx.sqlite” couldn’t be opened." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/yyyy/Library/Application Support/xxxx.sqlite, NSSQLiteErrorDomain=23}, ["NSSQLiteErrorDomain": 23, "NSFilePath": /var/mobile/Containers/Data/Application/yyyy/Library/Application Support/xxxx.sqlite]: file /xxxx/AppDelegate.swift, line 171

This error only appears on iOS 13.3.0. In earlier versions it is working correctly. I am not able to reproduce it in my site and the users with this error are increasing.

This is my code in the AppDelegate.swift file:

import CoreData
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, WebServerDelegate {

    var window: UIWindow?

    // Override point for customization after application launch.
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        DLog(className: String(describing: self), message: "")

        FirebaseApp.configure()
        Fabric.with([Crashlytics.self])

        let storageController = StorageController(managedContext: self.persistentContainer.viewContext)

        /* 
         * Other code ...
         */
        return true
    }

    /* 
     * Other delegate methods ...
     */

    // MARK: - Core Data stack
    lazy var persistentContainer: NSPersistentContainer = {
        let container = NSPersistentContainer(name: "xxxx")
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                fatalError("Unresolved error \(error), \(error.userInfo)")
            }
        })
        return container
    }()

    // MARK: - Core Data Saving support
    func saveContext () {
        let context = persistentContainer.viewContext
        if context.hasChanges {
            do {
                try context.save()
            } catch {
                let nserror = error as NSError
                fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
            }
        }
    }
}

According to Crashlytics, the error is in the line: container.loadPersistentStores... Is it an iOS 13.3.0 bug or is it a bad implementation of the CoreData? Do you know where is the problem?

Thanks!

BernatC
  • 979
  • 7
  • 12

0 Answers0