首先這里對安裝編譯源不做討論
若要了解 請參考
http://www.zuimoban.com/jiaocheng/ios/2016/0107/2656.html
http://www.reibang.com/p/a0a5ad711eb2
1.看文檔
https://developers.google.com/protocol-buffers/docs/reference/objective-c-generated
- 本頁面描述正是目標C代碼協(xié)議緩沖編譯器為任何給定的協(xié)議定義。
proto2和proto3生成的代碼之間的差異將突出顯示。
你應該閱讀proto2語種導游和/或proto3語種導游閱讀本文件前奖唯。
在桌面創(chuàng)建一個文件夾Protobuf 或者打開終端使用命令行touch Protobuf
在Protobuf 文件夾中創(chuàng)建一個 xxx.proto的文件 內(nèi)容格式必須按照文檔要求寫
cd 拖Protobuf文件夾到終端進來
最重要 DictationRecordItem這個是你創(chuàng)建的
protoc --plugin=/usr/local/bin/protoc-gen-objc DictationRecordItem.proto --objc_out="./"
[libprotobuf WARNING google/protobuf/compiler/parser.cc:546] No syntax specified for the proto file: DictationRecordItem.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
意思是你在創(chuàng)建的 DictationRecordItem.proto 文件里沒有聲明是使用哪個版本
syntax = "proto2"; or syntax = "proto3" 隨便寫一個 默認是proto2
String literals cannot cross line boundaries.
DictationRecordItem.proto:3:1: Expected ";".
請檢查標點符號 必須是這兩種否則無法通過編譯 " ;
DictationRecordItem.proto:4:8: Option "objc_package" unknown.
objc_package / package 設置的有問題 要么修改要么刪掉不寫
DictationRecordItem.proto:4:8: Option "outer_classname" unknown.
outer_classname 設置的有問題 要么修改要么刪掉不寫
Required fields are not allowed in proto3.
沒有通過proto3
protoc:0: warning: File 'DictationRecordItem.proto' has no package. Consider adding a new package to the proto and adding 'new.package = ' to the expected prefixes file ().
沒有包加一個唄 可以不加