CoreData causing error running Mac App - Is there a way to reset app so it starts fresh?

Yesterday I had issues with my CoreData database for my Multiplatform app which resulted in changes to the schema. I reset the CloudKit version and, on the iOS simulator, had to delete my app and run the code again to get it to work. My issue is with the macOS target. I'm getting the same fatalError (Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134140 "Persistent store migration failed, missing mapping model.") when running the macOS app but I can't figure out how to delete it so I can run it fresh like I did with the iOS version.

I've found where the application is created (in the Debug directory ultimately within my app's Build directory) and removed them all but when run the newly created application has the same error. Should I move up the directory structure and remove the entire app directory within Xcode/DerivedData or is there another way? Wanted an answer before I do something I can't go back from :)

Thanks, Kyra

Accepted Answer

Fixed it by destroying more my store through the code. Basically right after creating my container in the persistence file I added:

`do{

try container.persistentStoreCoordinator.destroyPersistentStore(at: container.persistentStoreDescriptions.first!.url!, type: .sqlite, options: nil) }catch{ print(error) }

Works great now. Solved it by asking this question in stackOverflow. Full question and answer here: https://stackoverflow.com/questions/73094220/how-to-fully-remove-macos-xcode-application

I have been noticing this issue constantly during the development of my macOS app even after doing the migration steps correctly. The sql file seems to occasionally jump back to a previous version for no apparent reason. I've filed a ticket in feedback, got no reply and am pretty much ready to ask for code level support from Apple.

Did you by any chance come by this specific issue in your development?

CoreData causing error running Mac App - Is there a way to reset app so it starts fresh?
 
 
Q