protobuf编译出错的解决方案(iOS,OSX)

2023-06-14,,

protobuf

最近使用protobuf,变编译工具时遇上一点问题.现在附上解决方案

编译过程

完全参照

https://github.com/alexeyxo/protobuf-objc

编译出错

遇到如下错误

./google/protobuf/objectivec-descriptor.pb.h:17:2: error: This file was
generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^
./google/protobuf/objectivec-descriptor.pb.h:18:2: error: incompatible with your
Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^
./google/protobuf/objectivec-descriptor.pb.h:19:2: error: regenerate this file
with a newer version of protoc.
#error regenerate this file with a newer version of proton.

解决方案

根据文档中

ln -s /usr/local/Cellar/protobuf/2.6.1/bin/protoc /usr/local/bin

作者应该使用2.6.1编译的,我将brew中的protobuf降级到了2.6.0(现在安装是3.1.0).

结果可以顺利编译

另外附上降级指南http://sanwen8.cn/p/5a9lM4E.html

protobuf编译出错的解决方案(iOS,OSX)的相关教程结束。

《protobuf编译出错的解决方案(iOS,OSX).doc》

下载本文的Word格式文档,以方便收藏与打印。