可能的几种情况:
1.本该导入.h文件实际导入了.m文件
2.检查TARGETS->Build phases->Compile Sources是否出现重复的文件,如果出现了删除它。
3.在头文件中声明并且初始化了一个变量
这是错误的:
MyFile.h
#import <Foundation/Foundation.h>
NSInteger const ABCMyConstant = 6;
应该是:
MyFile.h
#import <Foundation/Foundation.h>
NSInteger const ABCMyConstant;
MyFile.m
#import "MyFile.h"
NSInteger const ABCMyConstant = 6;
或者可以给变量加上static关键字
如:
MyFile.h
#import <Foundation/Foundation.h>
static NSInteger const ABCMyConstant=6;