iOS中出现(linker command failed with exit code 1)错误总结

第三方库报错

开发中难免需要导入第三方库,导库之后编译报错:

Undefined symbols for architecture armv7:  
  "_OBJC_CLASS_$_MyPageLogViewController", referenced from:  
      objc-class-ref in BaiduMobStatAppDelegate.o  
ld: symbol(s) not found for architecture armv7  
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

解决方法是在Build settings->Linking->Other Linker Flags中添加-ObjC如图所示:

iOS中出现(linker command failed with exit code 1)错误总结_第1张图片
添加-ObjC

静态库报错

导入第三方静态库.a的时候,有的时候也会报错:

Undefined symbols for architecture armv7:  
  "_OBJC_CLASS_$_BaiduMobStat", referenced from:  
      objc-class-ref in libLECLivePlayerUISDK.o  
      objc-class-ref in libLECLivePlayerSDK.o  
ld: symbol(s) not found for architecture armv7  
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

这种情况下先看下是否是导入的库重复了,或者是没有引用,如果是导库冲突了,删除按照官方文档重新导入,如果是没有引用,在Build settings->Search Path->Library Search Paths中引入静态库路径,如图:

iOS中出现(linker command failed with exit code 1)错误总结_第2张图片
导入静态库路径

你可能感兴趣的:(iOS中出现(linker command failed with exit code 1)错误总结)