前段时间公司接入一个摄像头SDK, 刚接入就一堆报错问题, 后面一步步排查, 才所有都解决了.
不得不说摄像头SDK的OC代码是真的水. 摊手
当时环境信息
XCode: 10.2.1 版本
iOS: 选中最低 10.0 版本
报错如下
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_AVAudioSession", referenced from:
objc-class-ref in xx.a(xxx.o)
objc-class-ref in xxx.a(xxx.o)
"_AVAudioSessionCategoryPlayAndRecord", referenced from:
不过我这边是用 pod 做本地库依赖, 所以我是在 .podspec 里面加入依赖, 如下
s.frameworks = 'AVFoundation'
报错如下
'xxx' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file 'xxxx' for architecture arm64
报错如下
Undefined symbols for architecture arm64:
"_QuarterPelWpAvg_8x4_20_asm", referenced from:
...
"_QuarterPelWpAvg_8x4_13_asm", referenced from:
...
"_QuarterPelWpAvg_4x4_12_asm", referenced from:
...
"_QuarterPelWpAvg_8x4_12_asm", referenced from:
...
"_QuarterPelWpAvg_8x4_11_asm", referenced from:
...
"_QuarterPelWpAvg_8x4_10_asm", referenced from:
...
"_QuarterPelWpAvg_8x4_03_asm", referenced from:
...
"_QuarterPelWP_8x4_00_asm", referenced from:
_QuarterPelWP_00_arm in xxxx(InterMc_arm.o)
"_QuarterPelWpAvg_8x4_30_asm", referenced from:
_QuarterPelWpAvg_30_arm in xxxx(InterMc_arm.o)
"_QuarterPelWpAvg_4x4_02_asm", referenced from:
_QuarterPelWpAvg_02_arm in xxxx(InterMc_arm.o)
"_QuarterPelWpAvg_8x4_02_asm", referenced from:
_QuarterPelWpAvg_02_arm in xxxx(InterMc_arm.o)
"_QuarterPelWpAvg_8x4_01_asm", referenced from:
_QuarterPelWpAvg_01_arm in xxxx(InterMc_arm.o)
"_QuarterPelWpAvg_8x4_00_asm", referenced from:
_QuarterPelWpAvg_00_arm in xxxx(InterMc_arm.o)
"_QuarterPelWP_4x4_33_asm", referenced from:
_QuarterPelWP_33_arm in xxxx(InterMc_arm.o)
"_QuarterPelWP_4x4_32_asm", referenced from:
.......
解决如下, Enable Testability 设为 NO
参考 https://blog.csdn.net/xqwin/article/details/81670560
报错如下
Undefined symbols for architecture arm64:
"_inflateSync", referenced from:
...
"_inflateReset", referenced from:
...
"_compress2", referenced from:
...
"_inflateEnd", referenced from:
...
"_deflate", referenced from:
...
"_compress", referenced from:
...
"_deflateReset", referenced from:
...
"_deflateBound", referenced from:
...
"_deflateInit2_", referenced from:
...
"_inflate", referenced from:
...
"_uncompress", referenced from:
...
"_deflateEnd", referenced from:
...
"_inflateInit_", referenced from:
...
"_inflateInit2_", referenced from:
...
"_deflateInit_", referenced from:
...
"_zlibCompileFlags", referenced from:
...
ld: symbol(s) not found for architecture arm64
同上面 AVFoundation, 在过滤输入框输入 libz, 然后选中 libz.tbd
同样, 我 .podspec 加入
s.libraries = 'z'
报错如下
Undefined symbols for architecture arm64:
"_iconv", referenced from:
....
"_iconv_open", referenced from:
....
"_iconv_close", referenced from:
....
ld: symbol(s) not found for architecture arm64
同上面 AVFoundation, 在过滤输入框输入 libiconv, 然后选中 libiconv.tbd
同样, 我 .podspec 加入
s.libraries = 'z', 'iconv'
报错如下
ndefined symbols for architecture arm64:
"_BZ2_bzDecompressInit", referenced from:
...
"_BZ2_bzDecompress", referenced from:
...
"_BZ2_bzDecompressEnd", referenced from:
...
ld: symbol(s) not found for architecture arm64
同上面 AVFoundation, 在过滤输入框输入 libbz2, 然后选中 libbz2.tbd
同样, 我 .podspec 加入
s.libraries = 'z', 'iconv', 'bz2'
当我开心打包成库的时候, 放到项目内…shi.t, 还有报错, 最终各种查资料, 换姿势, 原来只需要在项目内创建一个类(随便什么都行), 然后把 .m 改为 .mm , 就成功编译过了.
报错如下
Undefined symbols for architecture arm64:
"typeinfo for std::length_error", referenced from:
std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in (MagLowpowerDevice.o)
"___cxa_throw", referenced from:
std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in (MagLowpowerDevice.o)
"std::__1::basic_string, std::__1::allocator >::compare(char const*) const", referenced from:
CMagLowpowerDevice::RegDeviceNode(std::__1::basic_string, std::__1::allocator >) in (MagLowpowerDevice.o)
"std::length_error::~length_error()", referenced from:
std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in (MagLowpowerDevice.o)
"std::__1::basic_string, std::__1::allocator >::assign(char const*)", referenced from:
CMagLowpowerDevice::RegDeviceNode(std::__1::basic_string, std::__1::allocator >) in (MagLowpowerDevice.o)
"std::__1::__vector_base_common::__throw_out_of_range() const", referenced from:
std::__1::vector >::at(unsigned long) in (MagLowpowerDevice.o)
"std::__1::__vector_base_common::__throw_length_error() const", referenced from:
void std::__1::vector >::__push_back_slow_path(NODE_SERVER_INFO const&&&) in (MagLowpowerDevice.o)
"___cxa_free_exception", referenced from:
std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in (MagLowpowerDevice.o)
"operator delete[](void*)", referenced from:
CMagLowpowerDevice::SendMasterMegage(std::__1::basic_string, std::__1::allocator >&) in (MagLowpowerDevice.o)
CMagLowpowerDevice::SendNodeServerMegage(int, std::__1::basic_string, std::__1::allocator >&) in (MagLowpowerDevice.o)
CMagLowpowerDevice::NodeServerRecvProess() in (MagLowpowerDevice.o)
CCircleBuf::Release() in (CircleBuf.o)
CCircleBuf::Create(int) in (CircleBuf.o)
CCircleBuf::ReadOneFrame1(int&, VIDEO_BUF_HEAD&) in
CPPPPChannel::SafeDel(char*) in (PPPPChannel-861088B11FC92685.o)
至此, 整个坑算是走完了, 虽说编译是坑, 但摄像头用起来还算行. 只能说摄像头厂商那边根本没考虑对接人员快速上手SDK问题. ( 或许程序员并不算用户 ? )