iosswiftcore-datanspersistentcontainer

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


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


Solution

  • 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.