@@ -7,7 +7,7 @@ and code generator.
77
88It is intended for use with Apple's
99[ swift-protobuf] ( https://github.com/apple/swift-protobuf )
10- support for Protocol Buffers. Both projects contain
10+ support for Protocol Buffers. Both projects contain
1111code generation plugins for ` protoc ` , Google's
1212Protocol Buffer compiler, and both contain libraries
1313of supporting code that is needed to build and run
@@ -29,26 +29,92 @@ systems. Please see [DOCKER.md](DOCKER.md) and
2929
3030## gRPC dependencies are vendored
3131
32- Swift gRPC now includes vendored copies of the gRPC core
32+ Swift gRPC includes vendored copies of the gRPC core
3333library and ** BoringSSL** , an OpenSSL fork that is used by
3434the gRPC Core. These are built automatically in Swift Package
3535Manager builds.
3636
37- ## Building with Xcode
37+ ## Usage
38+
39+ The recommended way to use Swift gRPC is to first define an API using the
40+ [ Protocol Buffer] ( https://developers.google.com/protocol-buffers/ )
41+ language and then use the
42+ [ Protocol Buffer Compiler] ( https://github.com/google/protobuf )
43+ and the [ Swift Protobuf] ( https://github.com/apple/swift-protobuf )
44+ and [ gRPC-Swift] ( https://github.com/grpc/grpc-swift ) plugins to
45+ generate the necessary support code.
46+
47+ ### Getting the dependencies
48+
49+ Binary releases of ` protoc ` , the Protocol Buffer Compiler, are
50+ available on [ GitHub] ( https://github.com/google/protobuf/releases ) .
51+
52+ To build the plugins, run ` make ` in the [ Plugins] ( Plugins ) directory.
53+ This uses the Swift Package Manager to build both of the necessary
54+ plugins: ` protoc-gen-swift ` , which generates Protocol Buffer support code
55+ and ` protoc-gen-swiftgrpc ` , which generates gRPC interface code.
56+
57+ ### Using the plugins
58+
59+ To use the plugins, ` protoc ` and both plugins should be in your
60+ search path. Invoke them with commands like the following:
61+
62+ protoc <your proto files> \
63+ --swift_out=. \
64+ --swift_opt=Visibility=Public \
65+ --plugin=<path to protoc-gen-swift>`
66+
67+ protoc <your proto files> \
68+ --swiftgrpc_out=.
69+
70+ By convention the ` --swift_out ` option invokes the ` protoc-gen-swift `
71+ plugin and ` --swiftgrpc_out ` invokes ` protoc-gen-swiftgrpc ` .
72+
73+ The ` --swift_opt ` flag passes an option to ` protoc-gen-swift ` that
74+ makes message classes public, which is necessary to use them with
75+ gRPC. The ` --plugin ` option is only needed by older versions of
76+ ` protoc ` that are unable to find the plugin binaries when options
77+ are specified.
78+
79+ ### Building your project
80+
81+ Most ` grpc-swift ` development is done with the Swift Package Manager.
82+ For usage in Xcode projects, we rely on the ` swift package generate-xcodeproj `
83+ command to generate an Xcode project for the ` grpc-swift ` core libraries.
3884
3985The top-level Makefile uses the Swift Package Manager to
4086generate an Xcode project for the SwiftGRPC package:
4187
4288 $ make
4389
44- Then open ` SwiftGRPC.xcodeproj ` in Xcode. Due to present
90+ This will create ` SwiftGRPC.xcodeproj ` , which you should
91+ add to your project, along with setting build dependencies
92+ on ** BoringSSL** , ** CgRPC** , and ** gRPC** . Due to present
4593limitations in Package Manager configuration, the libz
4694dependency is not included in the generated Xcode project. If
4795you get build errors about missing symbols such as
4896` _deflate ` , ` _deflateEnd ` , etc., you can fix them by adding
4997` libz.tbd ` to the ** Link Binary With Libraries** build step
5098of the ** CgRPC** target.
5199
100+ Please also note that your project will need to include the
101+ ** SwiftProtobuf.xcodeproj** from
102+ [ Swift Protobuf] ( https://github.com/apple/swift-protobuf ) and
103+ the source files that you generated with ` protoc ` and the plugins.
104+
105+ Please see [ Echo] ( Examples/Echo ) for a working Xcode-based
106+ example and file issues if you find any problems.
107+
108+ ### Low-level gRPC
109+
110+ While the recommended way to use gRPC is with Protocol Buffers
111+ and generated code, at its core gRPC is a powerful HTTP/2-based
112+ communication system that can support arbitrary payloads. As such,
113+ each gRPC library includes low-level interfaces that can be used
114+ to directly build API clients and servers with no generated code.
115+ For an example of this in Swift, please see the
116+ [ Simple] ( Examples/Simple ) example.
117+
52118## Having build problems?
53119
54120grpc-swift depends on Swift, Xcode, and swift-proto. We are currently
0 commit comments