Why does Xcode says "Cannot find type 'NSPersistentContainer' in scope"?

3.7k views Asked by At

I just stared making a new Core Data project but without making any changes yet, I am getting this error. Not sure why.

enter image description here

1

There are 1 answers

1
Joakim Danielson On BEST ANSWER

You have named your application "CoreData" thus overwriting the name of the framework CoreData so what the compiler is complaining about is that your app doesn't have a type NSPersistentContainer.

Also, you have a warning on the import statement (import CoreData) that hints that something is wrong

Solution: Delete the project and create a new one with a more unique name, even something like MyCoreDataApp will do.