1

Im generating my core data model after changing my models files using Editor -> Create NSManagedObj...

I changed an entity relationship to a different entity (if this matters)

Iv cleaned my project and build folder.

But the generated files don't seem to be correct, they include files such as 'Entity.h' Which doesn't exist... As the only class files i see are 'Entity+CoreDataClass.h'

So i change the name manually to the all above errors and then i get a linker error:

duplicate symbol _OBJC_CLASS_$_Userinfo in:
    /Users/Me/Library/Developer/Xcode/DerivedData/test-fxdxcviituhcmoegqygwirddhuir/Build/Intermediates/test.build/Debug-iphonesimulator/test.build/Objects-normal/x86_64/Userinfo+CoreDataClass.o
duplicate symbol _OBJC_METACLASS_$_Userinfo in:
    /Users/Me/Library/Developer/Xcode/DerivedData/test-fxdxcviituhcmoegqygwirddhuir/Build/Intermediates/test/Debug-iphonesimulator/test/Objects-normal/x86_64/Userinfo+CoreDataClass.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Originally i created the project using an older version of Xcode, where the entity files such as 'Entity.h" were generated... Is this some sort of bug with Xcode after updating?

My entities are using the 'manual/none' codegen option. But i notice after building that the entity with the above linker error automatically changes to 'Class Definition'?

EDIT: Ok so setting the codegen to class definition to all entities stops the wrong file import errors. (but then still revert back to 'manual/none' afterwards. Except for my newly created entity. Where there is the error in the derriveddata for the +CoreDataClass.m file... where it does not include the +CoreDataClass in the import name. My +CoreDataClass.m file within my project does not include this error and is correct with the +CoreDataClass.

My project generated file:

#import "Userinfo+CoreDataClass.h"
#import "User+CoreDataClass.h"
@implementation Userinfo

@end

Where the error exists: (in derived sources)

#import "Userinfo+CoreDataClass.h"
#import "User.h"
@implementation Userinfo

@end
nicwhitts
  • 190
  • 1
  • 3
  • 22

2 Answers2

0

Try to click on project. Next click the "Show version editor" (the top right button on the picture) button and try to find duplicated references and remove it. enter image description here

Should solve the problem

Axel
  • 768
  • 6
  • 20
  • 1
    Thanks for the response, after posting i found this answer: http://stackoverflow.com/a/39394426/2859891 . Changing name and setting codegen to 'manual/none', building, then changing name back again seems to work. But Xcode still did not create the proper import names. I had to append the '+CoreDataClass' to each import. But this now builds without errors – nicwhitts Jan 11 '17 at 11:56
0

I think I found the answer, in your xcddatamodel file after choosing your entity. On the right panel, you will see a "Code Generation" DropDown. It might default to Swift, change it to Objective c and build the project. Your file will be generated.