@@ -8,20 +8,11 @@ If you've used Protocol Buffers before then generating gRPC Swift stubs should b
8
8
unfamiliar with Protocol Buffers then you should get comfortable with the concepts before
9
9
continuing; the [ Protocol Buffers website] ( https://protobuf.dev/ ) is a great place to start.
10
10
11
- The [ ` grpc-swift-protobuf ` ] ( https://github.com/grpc/grpc-swift-protobuf ) package provides
12
- ` protoc-gen-grpc-swift ` , a program which is a plugin for the Protocol Buffers compiler, ` protoc ` .
13
-
14
11
You can use the protoc plugin from the command line directly, or you can make use of a
15
12
[ Swift Package Manager build plugin] ( https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/Plugins.md )
16
13
convenience which adds the stub generation to the Swift build graph.
17
14
You may use the build plugin either from the command line or from Xcode.
18
15
19
-
20
- > ` protoc-gen-grpc-swift ` only generates gRPC stubs, it doesn't generate messages. You must use
21
- > ` protoc-gen-swift ` to generate messages in addition to gRPC Stubs.
22
-
23
-
24
-
25
16
## Using the build plugin
26
17
27
18
The build plugin (` GRPCProtobufGenerator ` ) is a great choice for convenient dynamic code generation, however it does come with some limitations.
@@ -104,13 +95,18 @@ lower in the file hierarchy supersedes one above it.
104
95
105
96
### Using protoc
106
97
98
+ The [ ` grpc-swift-protobuf ` ] ( https://github.com/grpc/grpc-swift-protobuf ) package provides
99
+ ` protoc-gen-grpc-swift ` , a program which is a plugin for the Protocol Buffers compiler, ` protoc ` .
107
100
To generate gRPC stubs for your ` .proto ` files directly you must run the ` protoc ` command with
108
101
the ` --grpc-swift_out=<DIRECTORY> ` option:
109
102
110
103
``` console
111
104
protoc --grpc-swift_out=. my-service.proto
112
105
```
113
106
107
+ > ` protoc-gen-grpc-swift ` only generates gRPC stubs, it doesn't generate messages. You must use
108
+ > ` protoc-gen-swift ` to generate messages in addition to gRPC Stubs.
109
+
114
110
The presence of ` --grpc-swift_out ` tells ` protoc ` to use the ` protoc-gen-grpc-swift ` plugin. By
115
111
default it'll look for the plugin in your ` PATH ` . You can also specify the path to the plugin
116
112
explicitly:
0 commit comments