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:
- Check Build phases in Target settings.
- Check if any file exists twice or once.
- If file exist twice delete one. If not delete file in the bottom which is the latest one.
- 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.