Problems using Core data.

Problems using Core data.

I have version 14.3.12 of Xcode installed. Unfortunately, after creating a "Libro" entity and using the NSMMenagedObject Subclass creation function, I have an error code in the files created by it. That is, two new files are created respectively with the name “Libro+CoreDataClass” and “Libro+CoreDataProperties”. The following code is created in the first file: import Foundation import CoreData

@objc(Libro) public class Libro: NSManagedObject {

} the following error message appears on the same line as the "Libro" class definition: invalid redeclaration of 'Libro' the compilation fails and is not executed. Does anyone have a solution?

When you create a new Core Data project in Xcode, the project is set to automatically create subclasses for your Core Data entities when you build the project. When you create a NSManagedObject subclass manually, you now have two copies of the subclass: the one Xcode generates and the one you created. You can have only one copy of the subclass.

To fix the problem either remove the NSManagedObject subclass files you created or tell Xcode not to generate subclasses for your entities. Read the following article for more details:

https://www.swiftdevjournal.com/core-data-code-generation/

Thanks for the reply. I'm quite confused. I didn't create anything manually. I limited myself to defining the entities and then using the "Editor>Create NSManaged Subclass" function I tried to create the two files of ..Class and ...Properties. Xcode created the two files and inside it encoded the Class definition with the name of the entity but at this point underlining the name of the entity it gives the error message "invalid Redefinition.... If I delete the two files created by Xcode I no longer have the definition of the class to refer to to save the data anywhere.

Problems using Core data.
 
 
Q