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.
In my case, the problem came from bringing in files from another project to reuse. I was not careful to "Copy files if needed" in the copy dialog box, and instead of creating new copies in the new project, it referred to the files in the original project. Once I removed the references and re-copied the files correctly, all was OK.
I had a similar problem, yet I didn't have two copies of the source files. In my case, I had the following situation:
Class A gave the error above and Class B had a property using Class A's type.
The problem was that in Class B I called #import "Class A" in both the .h and the .m file. This caused the problem above in my case. Hope this helps anyone.
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 ...
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.
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.
This error occurs because of giving same variable name to different objects. This is the error coming after Xcode7.0. So to overcome this issue just Go to Build Setting and search for No Common Blocks and set it NO.
And build again you will not get this error again.
CheersKP