protobuf在cocoapods中使用问题记录

2021-02-18  本文已影响0人  修正

使用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

上一篇 下一篇

猜你喜欢

热点阅读