error: filename "x+CoreDataClass.swift" used twice:

I am trying to set up a simple core data app. But after I create the NSManagedObject subclasses from the Editor menu I get numerous errors that I do not understand.


<unknown>:0: error: filename "Fields2+CoreDataClass.swift" used twice: '/Current Projects/Stages/Stages/CoreData/Fields2+CoreDataClass.swift' and '/Users/me/Library/Developer/Xcode/DerivedData/Stages-bvmokbzazpxlmwaxrpiatcooijvt/Build/Intermediates.noindex/Stages.build/Debug-iphoneos/Stages.build/DerivedSources/CoreDataGenerated/Stages/Fields2+CoreDataClass.swift'

<unknown>:0: note: filenames are used to distinguish private declarations with the same name


Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1


In the extension for Fields2 I get


'Fields2' is ambiguous for type lookup in this context


then I get

@NSManaged only allowed on an instance property or method for all of the properties in Fields2


Is this a bug? Or am I doing something wrong? What is going on and how do I fix it?

  • This occurred to me after I had setup my xcdatamodel. Since my model had entities with like properties, I created one and then copy/pasted my template and then updated the new entitys' names. What I forgot to do, and was causing this problem, was to go into the configuration and update the class names there (they all had the same class name due to my copy/paste).

Add a Comment

Replies

>Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1


See https://stackoverflow.com/questions/38496582/error-swiftc-failed-with-exit-code-1


It might fix everything, or nothing more than just that error, but it's where I'd start.

As indicated by others, set the Codegen for your CoreData entities in your CoreData xcdatamodel file to Manual/None,

If you do not, you may get these build errors.

Code Block
<unknown>:0: error: filename "SomeAwesomeEntity+CoreDataClass.swift" used twice:
<unknown>:0: error: filename "SomeAwesomeEntity+CoreDataProperties.swift" used twice: