Create plugin with protobuf support
flutter create -t plugin -i swift -a kotlin plugin_with_protobuf
Quick check: cd plugin_with_protobuf/example flutter run
brew install protobuf brew install swift-protobuf
brew tap dart-lang/dart brew install dart pub global activate protoc_plugin
export PATH=$PATH:~/flutter/bin: ~/.pub-cache/bin
Android Studio: Protobuf Support VSCode: vscode-proto3
- Create person.proto file
protoc --dart_out=./lib/gen ./protos/person.proto
dependencies: protobuf: any
protoc --swift_out=./ios/Classes ./protos/person.proto
then modify podspec for iOS project at: ios/plugin_with_protobuf.podspec Adding:
- s.dependency 'SwiftProtobuf', '~> 1.4'
- s.ios.deployment_target = '9.0'
Right click on iOS -> Flutter -> Open iOS module in XCode
Method channel should be in SwiftPluginWithProtobufPlugin.swift Search for that file -> see PluginWithProtobufPlugin.m
plugin_with_protobuf/ios/Classes/SwiftPluginWithProtobufPlugin.swift
- Try to run on Android simulator/device to test Gradle build file
- Implement in Kotlin, can open Android Studio project in another window plugin_with_protobuf/android/src/main/kotlin/com/example/plugin_with_protobuf/PluginWithProtobufPlugin.kt