Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to eliminate core data sqlite warning message when application terminates?

Since upgrading to High Sierra, I've been getting these warnings when my core data application terminates:

BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use

I haven't seen any actual problems, but I'm wondering if there is some tear down code I should have added in applicationShouldTerminate()?

At the moment all I do is save the context if it has changes before returning .terminateNow.

like image 622
closetCoder Avatar asked Dec 30 '17 22:12

closetCoder


1 Answers

OK, I figured it out. Since my persistent store contained sensitive data, I was encrypting the files on disk as the final step before shutting down. However, the Core Data stack was still referencing them at this point in the close down process.

The solution was to add code to remove the persistent stores before running the code to encrypt the files.

    for store in managedObjectContext!.persistentStoreCoordinator!.persistentStores {
        try! managedObjectContext!.persistentStoreCoordinator!.remove(store)
    }
like image 180
closetCoder Avatar answered Nov 05 '22 00:11

closetCoder