Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 2.65 KB

plugin.md

File metadata and controls

55 lines (39 loc) · 2.65 KB

protoc Swift gRPC plugin

gRPC Swift provides a plugin for the protocol buffer compiler protoc to generate classes for clients and services.

Building the Plugin

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.

Plugin Options

The table below lists the options available to the protoc-gen-grpc-swift plugin:

Flag Values Default Description
Visibility Internal/Public Internal ACL of generated code
Server true/false true Whether to generate server code
Client true/false true Whether to generate client code
FileNaming FullPath/PathToUnderscores/DropPath FullPath How to handle the naming of generated sources, see documentation
ExtraModuleImports String Extra module to import in generated code. This parameter may be included multiple times to import more than one module
ProtoPathModuleMappings String The path of the file that contains the module mappings for the generated code, see swift-protobuf documentation

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=.