-1

Error

I'm trying to use the CoreData functionality but when Xcode creates the two files (xx+CoreDataClass.swift and xx+CoreDataProperties.swift) Xcode gives me this error. The problem is: there's xx+CoreDataClass.swift is in the project's directory and in another directory that it creates when it compiles... so this error persist even if I delete the second one. What should I do??

cam0347
  • 23
  • 3
  • 1
    You need to decide how you want to handle those files, should Xcode always generate new ones when something is changed to an entity or do you want to maintain the files yourself. When selecting an entity in your model in Xcode you can use the setting `Codegen` to set that. [Here is an article](https://useyourloaf.com/blog/core-data-code-generation/) explaining this further – Joakim Danielson Dec 10 '19 at 18:29

2 Answers2

2

This is most often bugs in Xcode where it gets confused about generated files (I literally ran into this exact problem this morning....)

The solution generally is to close Xcode, delete DerivedData, and reopen Xcode.

DerivedData is in ~/Library/Developer/Xcode/DerivedData/. You can remove the whole directory, or just the subdirectory related to your project.

"Delete DerivedData" is an incredibly common solution to Xcode problems, and has been for years. Most of us have some kind of alias to simplify it. This is mine:

alias cdd='cd ~/Library/Developer/Xcode/DerivedData/'
Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • 1
    I just leave a finder alias to it on the desktop. :) – matt Dec 10 '19 at 19:19
  • Uhh, I tried this, but now there are two other errors: Multiple commands produce '/Users/camillozavattaro/Library/Developer/Xcode/DerivedData/School_trace-bhehebmpvrzmwkcgixlhaplzlrgi/Build/Intermediates.noindex/School trace.build/Debug-iphoneos/School trace.build/Objects-normal/arm64/Valutation+CoreDataProperties.o': 1) Target 'School trace' (project 'School trace') has compile command for Swift source files 2) Target 'School trace' (project 'School trace') has compile command for Swift source files One a file (Valutation+CoreDataProperties.o and Valutation+CoreDataClass.o) :( – cam0347 Dec 10 '19 at 20:58
0

This kind of error generated some times because of your codegen property of Managed Class. You have to change your codegen to Manual/None from attributor.

enter image description here

Rakesh Patel
  • 1,673
  • 10
  • 27