Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI preview crash after modify core data entity's attribute

Prior to this issue, the preview is running fine. However, after I have changed the type of the attribute (e.g. from String to Float) inside a .xcdatamodeld file and modify the manual definition file accordingly, which looks similar to this

public class test01: NSManagedObject, Identifiable {
    @NSManaged public var var01: String
    ...
}

The simulation crashes on first few tries but works again after I removed the application inside the simulation iPhone. But then when I tried to use the preview, it always show an error tab saying that it always crashed in updating the view, even the simplest starter file, "Hello World", given when creating the SwiftUI preview file.

Application Specific Information: Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134140 "Persistent store migration failed, missing mapping model." UserInfo={destinationModel=() isEditable 0

At this point I could not find the solution, any idea on this bug/problem?

like image 687
np2314 Avatar asked Feb 19 '20 08:02

np2314


1 Answers

Try deleting the preview canvas simulators as well. They exist in:

~/Library/Developer/Xcode/UserData/Previews/Simulator Devices/

The preview canvas probably has the old version of the data model.

You may need to do this command at command line:

killall -9 com.apple.CoreSimulator.CoreSimulatorService

And restart XCode as well.

like image 125
Monica Granbois Avatar answered Oct 11 '22 11:10

Monica Granbois