protoc gRPC Swift plugingRPC Swift provides a plugin for the protocol buffer
compiler protoc to generate classes for clients and services.
The protoc-gen-grpc-swift plugin can be built by using the Makefile in the
top-level directory:
$ make plugins
The Swift Package Manager may also be invoked directly to build the plugin:
$ swift build --product protoc-gen-grpc-swift
The plugin must be in your PATH environment variable or specified directly
when invoking protoc.
The Visibility option determines the access control for generated code.
The Server option determines whether server code is generated. The
generated server code includes a protocol which users must implement
to provide the logic for their service.
The Client option determines whether client code is generated. The
generated client code includes a protocol and a class conforming to that
protocol.
The TestClient option determines whether test client code is generated.
This does not include the protocol generated by the Client option.
The FileNaming option determines how generated source files should be named.
foo/bar/baz.proto will generate foo/bar/baz.grpc.protofoo/bar/baz.proto will generate foo_bar_baz.grpc.protofoo/bar/baz.proto will generate baz.grpc.protoThe ProtoPathModuleMappings option allows module mappings to be specified. See the SwiftProtobuf documentation.
The GRPCModuleName option allows the name of the gRPC Swift runtime module to be specified. The value, if not specified, defaults to "GRPC".
Note: most users will not need to use this option. It is intended as a workaround for CocoaPods users who may end up with a transitive dependency on the gRPC core C library whose module name is also "GRPC".
To pass extra parameters to the plugin, use a comma-separated parameter list
separated from the output directory by a colon. Alternatively use the
--grpc-swift_opt flag.
For example, to generate only client stubs:
protoc <your proto> --grpc-swift_out=Client=true,Server=false:.
Or, in the alternate syntax:
protoc <your proto> --grpc-swift_opt=Client=true,Server=false --grpc-swift_out=.