Duplicate symbol error when adding NSManagedObject subclass, duplicate link Duplicate symbol error when adding NSManagedObject subclass, duplicate link ios ios

Duplicate symbol error when adding NSManagedObject subclass, duplicate link


If you do not generate managed object subclass automatically, then don't forget to check "Codegen" settings for an Entity in Data Model Inspector:

enter image description here


Edit: Thanks to some help from @iPeter, found the following:

After doing Editor > Generate NSManagedObject files, if you trash the files BEFORE building, your project should build no problems.

Trash these files

Then #import "myManagedObjectName+CoreDataClass.h" (where the MO name is the one in the entity inspector in core data) into any classes where you require those Managed Objects.

In other words, you don't require any of the actual ManagedObject files in your folder. Xcode keeps the generated ones in your Derived Data folder.

If for some reason you need those files to remain in your file directory, the following workaround will work. Go to your Target and delete the CoreDataClass sources in your Compile Sources.

Before

Leaving you with this:

After

  • Most of the new attributes / relationships I added after the initial generation of ManagedObject subclasses were available as properties after a build. In one case where I renamed an existing relationship, I had to do Editor > Generate NSManagedObject Subclasses again, then I trashed the new files in my folder, built, and everything worked OK.

Just wrote a blog post that includes this info for anybody interested.


You should delete all these entities, change "Codegen" settings to "Manual/None" for them in Data Model Inspector, and generate entities again. It works good! You don't need to remove +CoreDataClass.h files from Compile Source. You don't need to mark entities as abstract. You don't need to generate classes by yourself. You should change only "Codegen" settings and regenerate entities automatically.enter image description here