duplicate symbols for architecture i386 clang

Just to add to the possible solutions.

In my case I had accidentally declared and initialized a variable in a header file.

For example this is wrong:

MyFile.h

#import <Foundation/Foundation.h>

NSInteger const ABCMyConstant = 6;

It should be:

MyFile.h

#import <Foundation/Foundation.h>

NSInteger const ABCMyConstant;

MyFile.m

#import "MyFile.h"

NSInteger const ABCMyConstant = 6;

Another reason this error often happens is accidentally importing the .m file instead of the .h.


Steps:

  1. Check Build phases in Target settings.
  2. Check if any file exists twice or once.
  3. If file exist twice delete one. If not delete file in the bottom which is the latest one.
  4. Build again.

Go to Build Setting and search for No Common Blocks and set it NO. And build again you will not get this error again.