iOS 报错 Undefined symbols for architecture x86_64:解决方法

     联系人:石虎 QQ:1224614774  昵称: 嗡嘛呢叭咪哄

                             QQ群:807236138  群称: iOS 技术交流学习群

一、报错详情

 

Undefined symbols for architecture x86_64:

"_OBJC_CLASS_$_Person", referenced from:

_OBJC_CLASS_$_Dog in Dog.o

objc-class-ref in ViewController.o

"_OBJC_METACLASS_$_Person", referenced from:

_OBJC_METACLASS_$_Dog in Dog.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

 

 

二、解决方法

1:

iOS 报错 Undefined symbols for architecture x86_64:解决方法

2:在 build Phases 下操作如下

iOS 报错 Undefined symbols for architecture x86_64:解决方法

3:添加类文件

iOS 报错 Undefined symbols for architecture x86_64:解决方法

 

4:编译成功

iOS 报错 Undefined symbols for architecture x86_64:解决方法

 

 

 

三、造成 bug 原因,以及如何避免

 

1.造成 bug 原因是其它类没有参加编译造成的,这种原因又分成二种

 

2.如何避免

第一种:此框一定要勾选

iOS 报错 Undefined symbols for architecture x86_64:解决方法

 

第二种:此框一定要勾选

iOS 报错 Undefined symbols for architecture x86_64:解决方法

 

注意:如果忘记勾选,就在项目中的 Build Phases 中的 Compile Sources 中添加(详细前看图4)

 

谢谢!!!