protobuf在cocoapods中使用问题记录

使用AliyunLogObjc报错

# 要先安装 protobuf
brew install protobuf
# 安装指定的版本
brew install [email protected] 

# 根据提示,添加 protoc 到环境
echo 'export PATH="/usr/local/opt/[email protected]/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 [email protected] 

然后删除 cocoapods缓存

rm -rf Pods/AliyunLogObjc
pod cache clean AliyunLogObjc

最后 pod update

你可能感兴趣的:(protobuf在cocoapods中使用问题记录)