duplicate symbols for architecture i386 clang duplicate symbols for architecture i386 clang objective-c objective-c

duplicate symbols for architecture i386 clang


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 bottomwhich is the latest one.
  4. Build again.


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;