不说废话,直接贴步骤
brew install protobuf
brew tap dart-lang/dart
brew install dart
dart 安装好后,就有pub命令了。
pub global activate protoc_plugin
将protoc-gen-dart添加到path
在用户根目录:.bash_profile添加
export "$PATH:$PWD/.pub-cache/bin"
安装好后,就有protoc-gen-dart 命令了。
.proto
文件编译成dart文件protoc --dart_out=. test.proto
如果没有添加path
protoc --dart_out=. test.proto --plugin ~/.pub-cache/bin/protoc-gen-dart
在pubspec.ymal中添加以下依赖
protobuf: ^0.13.4