1 duplicate symbol for architecture i386

I am facing a critical problem here, Xcode throws strange exception while building it's "

duplicate symbol _selected in: /Users/mhgaber/Library/Developer/Xcode/DerivedData/اProject-Name-aopcbghvorqhdwbyudzqsyhtekcu/Build/Intermediates/Project-Name.build/Debug-iphonesimulator/Project-Name.build/Objects-normal/i386/ClassX.o /Users/mhgaber/Library/Developer/Xcode/DerivedData/Project-Name-aopcbghvorqhdwbyudzqsyhtekcu/Build/Intermediates/Project-Name.build/Debug-iphonesimulator/Project-Name.build/Objects-normal/i386/ClassY.o ld: 1 duplicate symbol for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I searched a lot but I didn't find anything help me please


Look at both the files for ClassX and ClassY - What targets are they included in? Basically the _selected method is duplicated in both of them. I am going to guess this is a plain C method that happens to be named the same in both files. Try renaming _selected in one of the files.

In my case, I was declaring a const in a header file, which worked fine when building and running on the device (iPhone 5), however when attempting to simulate a 4S, all of a sudden I had some 300 "duplicate symbols".

It turns out I needed to also mark the const as static and the issue went away. Presumably it was trying to redefine the constant every time the header was referenced. The compiler isn't smart enough to just make constants static? Didn't think that would be necessary, but I guess it is.

const CGFloat kTitleAnimateDistance = 50.f;

Needed to be:

const static CGFloat kTitleAnimateDistance = 50.f;

Some time you accidentally importing the .m file instead of the .h due to which this error comes. Please check and If this is not the reason, then perform the following steps

1- Check Build phases in Target settings.

2- Go to compile source section.

3- Check if any file exists twice or once.

4- If file exist twice delete one.

5- Build again.

I was having the same problem and @dtrotzjr 's answer gave me a hint as to what could be causing it.

In my case I had a plain C void function in my framework (which xcode was complaining about as a duplicate symbol) and i needed to declare it as static void

I had the same issue. I was including a .h file with a number of const strings, methods and a struct. When I changed them all to static except the only mutable variable I wanted, it compiled just fine.

Need Your Help

How to display all types of an object (in Scala)?

scala reflection types

With the isInstanceOf method, one can check the type of an object. For example:

WPF ListView setting SelectedItem

wpf listview wpf-controls selecteditem

I've tried to search for an answer to this but I'm not having any luck. Basically I have a listview that is bound to a collection returned from a view model. I bind the selected item of the list ...