protobuf在cocoapods中使用问题记录

使用AliyunLogObjc报错

# 要先安装 protobuf
brew install protobuf
# 安装指定的版本
brew install protobuf@3.6 

# 根据提示,添加 protoc 到环境
echo 'export PATH="/usr/local/opt/protobuf@3.6/bin:$PATH"' >> ~/.zshrc
Xcode build error

这是因为AliyunLogObjc会使用 protobuf 生成代码,而终端使用的protobuf版本,跟pod中在中依赖的protobuf版本不一致造成的

#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif

所以需要根据AliyunLogObjc.podspec中依赖去确定 protobuf 的版本,
这时需要先重新安装protobuf

brew uninstall protobuf   
brew install protobuf@3.6 

然后删除 cocoapods缓存

rm -rf Pods/AliyunLogObjc
pod cache clean AliyunLogObjc

最后 pod update

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容