Learning about data technologies on iOS?
I am the author of Core Data Fundamentals with Swift, CloudKit, iOS Data Persistence: The Big Picture, and eight other courses on Pluralsight.
Deepen your understanding by watching the courses!
I am the author of Core Data Fundamentals with Swift, CloudKit, iOS Data Persistence: The Big Picture, and eight other courses on Pluralsight.
Deepen your understanding by watching the courses!
Resolving Failed to Load Model Named... with Core Data
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:
- YourModelName.xcdatamodeld
- let container = NSPersistentContainer(name: “YourModelName”)