Xcode编译异常和警告汇总(持续更新中)

1.Method definition for 'xxx' not found

xxx的方法没有实现
出现原因.h声明了xxx方法但是.m没有实现xxx方法
解决方法:在类的.m文件实现xxx方法
 
2. Instance variable ‘xxx' accessed in class method  
在类方法中访问了'xxx’实例变量
出现原因:在类方法中使用了实例变量
解决方法:如果真得需要在类方法中使用某个变量,可以把这个变量定义成全局变量,而不要实例变量,如在类方法外面定义变量(就是定义一个普通的全局变量)  
 
3.Cannot assign to 'self' outside of a method in the init family
my solution:
如果你的方法是一个初始化方法,则方法名必须用“init”开始,或者,你也可以把方法改为一个类方法,返回一个单例对象,我的问题方法如下:
-(id)initwithPage:(unsigned)pageNum {...}
注意小写‘w’
我把它改为:
-(id)initWithPage:(unsigned)pageNum {...}
注意大写‘W’
我的问题就解决了。
 
4.Could not load NIB in bundle with name XXX
my solution:
因为我是用Storyboard,但是却用ViewController的方法加载,所以出错了,改为:
UIStoryboard *sboard = [UIStoryboard storyboardWithName:@"StoryboardFileName" bundle:nil];
YourViewController *vc1 = [sboard instantiateInitialViewController];

5.Error:Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7d90880> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key currentTime.'
my solution:
选中 'currentTime'控件所在的storyboard(或nib),点击'currentTime'控件,storeboard左侧的View Controller Scene中的对应控件也会选中,在Scene选中控件中右键弹出窗口查找删除无效的Referencing Outlets连接,问题解决,
6.Error:-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x7d1b3c0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x7d1b3c0'
my solution:
原来是我把NSMutableDictionary错写成NSMutableArray,包括相应的方法调用,改过来就好了,

7、error: macro names must be identifiers YourProject_prefix.pch

原因: 因为你弄脏了预处理器宏,在它处于<Multiple Values>的时候修改了它

解决方法: Configiration选择All Configirations,清空它 然后分别重新定义你的Debug,Release,Distributin预处理器宏吧

8、warning: no rule to process file '$(PROJECT_DIR)/LoadingView.h' of type sourcecode.c.h for architecture armv6

原因: Target里Compile Sources里含有头文件 了,那里面不需要头文件

解决方法: 从Target里Compile Sources里删除头文件

9、Command /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng failed with exit code 1

原因: png图像文件拷贝失败,看看信息上面提示Can't find哪个文件,一般都是从文件系统里删除文件而没有通过Xcode删除造成的,Xcode的项目配置文件依然纪录着这个文件的引用

 解决办法: 给文件系统里增加相应的文件,或者从Xcode的Groups & Files删除它,或者从Target的Copy Bundle Resources里删除它

10、Code Sign error: The identity 'iPhone Developer: Your Name' doesn't match any valid certificate/private key pair in the default keychain

原因: 签名错误

解决办法: Target -> Get Info -> Build -> Code Signing -> 修改签名 

记得左上角的Configuration类型要跟当前Build类型对应(Debug, Release, Distribution),否则改了也白改

11、could not create bundle folder for versioned model *.moda(好像是这个后缀名的这个文件)

原因:编译一次会产生一个新的

解决办法:应该把编译产生出来的moda文件都删了,然后clean下工程,重新build即可

 
原文地址:https://www.cnblogs.com/limicheng/p/3808208.html