Search code examples
swiftxcodexcode10

File name used twice Xcode


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??


Solution

  • 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/'