I often got a crash when moving model file from project to project. Any idea why? If I create it from Xcode, and create entity manually, it does not happen. Why?
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
let modelURL = NSBundle.mainBundle().URLForResource("Model", withExtension: "momd")!
return NSManagedObjectModel(contentsOfURL: modelURL)!
}()
The file extension is not momd
, but xcdatamodel
. But that should be not a problem. Pervious project with Model
and same name was working.
File is added to the target:
and in console you can see it is exist in the right place:
I found this but it was not working. By the way it is something wrong with compilation. I removed model file, added a new empty model with previous naming but now from Xcode. And then edited the model file manually, and inserted the relating xml tags.