Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate interface declaration for class 'Foo'

I was working on my program, and it seems something in the settings changed. Suddenly I have the error "Duplicate interface declaration for class 'Foo'". It mentions a header file being duplicated but there's only one copy.

Interestingly this is only happening in debug mode, not device mode.

Does anyone have any idea what might be wrong?

I am using Objective-C++ and some static libraries.

like image 831
John Smith Avatar asked Oct 12 '10 05:10

John Smith


3 Answers

I had exactly the same problem. I had two copies of the header and had deleted the old one by deleting the reference to it in Xcode. There was then only one reference of the header which pointed to the new header file in the project navigator.

After actually deleting the old header from the file system, the problem went away.

It could be a bug in Xcode. Maybe sometimes when you delete a reference to a file, part of the reference still remains in the project file.

like image 165
RohinNZ Avatar answered Sep 20 '22 21:09

RohinNZ


I have this error message and I don't have the the duplicate header or duplicate imports. The problem is that I've renamed the header file and Xcode somehow keep them cached, that gives the build error.

I did the following to fix this. Hope it helps those that already tried other answer and still got the errors.

  1. Clean project(s)
  2. Delete the "Derived Data" (Organizer > Projects tab, select the project and click Delete)
  3. Restart Xcode
  4. Build
like image 36
Andy Avatar answered Sep 19 '22 21:09

Andy


I found the problem. There were two copies of the header file and Xcode got confused.

Now the mystery is how Xcode decided to copy these files by itself ...

like image 10
John Smith Avatar answered Sep 22 '22 21:09

John Smith