Search code examples
swiftxcodemacoscocoacore-data

How to completely reset CoreData for an Xcode project?


My macOS application is a mess right now. I made some big changes to my Core Data model, and now, just launching the app causes the app and Xcode to crash. The app's crash log reveals the following reason for the crash:

Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134140 "Persistent store migration failed, missing mapping model."

I don't want to create a mapping model. I don't care about the old CoreData model. I want all that data to go away. I have tried the following things:

  1. Deleting Derived Data.
  2. Deleting the ~/Library/Application Support/APP_NAME/ folder.
  3. Using NSBatchDeleteRequest to delete all the entities.

I want to start fresh (without creating a completely new project). What do I need to do to start all over again with a fresh Core Data dataset ?


Solution

  • Search in the Finder for yourAppName.sqlite. I found one in

    ~/Library/Containers/yourcompany.yourAppName/Data/Library/Application Support/yourAppName/