You’ve done the work to get your Core Data model ready, but right when you hit run, wham. Your debug output log shows:
Failed to load model named ModelName
You you may experience one of these when you attempt to access your persistent container:
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
What in the world is going on?
Double-check Target Membership
This is particularly important if you happend to have copied and pasted and
.xcdatamodeld file between projects.
Double-check Model Name
Your model name needs to match throughout the various places you refer to it. Things can get out of sync if you ever rename your model.
Check to make sure that the following all match:
- let container = NSPersistentContainer(name: “YourModelName”)
comments powered by Disqus