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:解决方法_第1张图片

2:在 build Phases 下操作如下

iOS 报错 Undefined symbols for architecture x86_64:解决方法_第2张图片

3:添加类文件

iOS 报错 Undefined symbols for architecture x86_64:解决方法_第3张图片

 

4:编译成功

iOS 报错 Undefined symbols for architecture x86_64:解决方法_第4张图片

 

 

 

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

 

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

 

2.如何避免

第一种:此框一定要勾选

iOS 报错 Undefined symbols for architecture x86_64:解决方法_第5张图片

 

第二种:此框一定要勾选

iOS 报错 Undefined symbols for architecture x86_64:解决方法_第6张图片

 

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

 

谢谢!!!

本账号主要分享我成长过程中的各种心得感悟,包括技术总结, iOS、Swift 和 Mac 相关技术文章、工具资源、参与技术讨论,整理开发技巧、让学习成为一种享受!

iOS 报错 Undefined symbols for architecture x86_64:解决方法_第7张图片

你可能感兴趣的:(iOS,解决bug)