No Description

Tim Burks 27334787ed Merge pull request #56 from grpc/internal_access 8 years ago
Assets 8013cc8423 Remove unused gRPC.xcodeproj (replaced by the generated SwiftGRPC.xcodeproj) 9 years ago
Docker 0b67d3ded6 Update Dockerfile for Protocol Buffers v3.2.0 release. 8 years ago
Examples f3926c5c6a Change access level for generated classes and methods from "public" to "internal". 8 years ago
Plugin f3926c5c6a Change access level for generated classes and methods from "public" to "internal". 8 years ago
Sources ee457d8663 Make Call message queue length and max length public. 9 years ago
Tests 44903ec7e3 Convert examples to use CountDownLatch, update version to 0.1.6 9 years ago
third_party 1f99975087 Update Xcode-based examples for Swift 3.1, Xcode 8.3.2, and other build problems. 8 years ago
.gitignore 37922f1ae7 Add rudimentary installation instructions to plugin 9 years ago
.gitmodules 63c6acfa40 Move CgRPC, gRPC, and QuickProto to "Sources" directory and add new top-level Package.swift. 9 years ago
.swift-version b7dcb9e04c Add Travis build and test configuration. 9 years ago
.travis-install.sh a7927827eb Add missing dependencies to travis configuration. 9 years ago
.travis.yml a7927827eb Add missing dependencies to travis configuration. 9 years ago
CONTRIBUTING.md 98a8b64da5 Update README and CONTRIBUTING. 9 years ago
DOCKER.md 7a8dbb0371 Update Docker instructions to download a pre-built protoc. 9 years ago
LICENSE d983798ec5 Fix license date (thomasvl@) 9 years ago
LINUX.md cd67135c18 Fixed plugin for use on Linux. 9 years ago
Makefile 1f99975087 Update Xcode-based examples for Swift 3.1, Xcode 8.3.2, and other build problems. 8 years ago
OVERVIEW.md a11da8644e Fix font weight formatting in OVERVIEW.md 8 years ago
PATENTS 36f2bde28e Add PATENTS declaration 9 years ago
Package.swift 20e0cf1bb2 Reorganize vendored gRPC core code, moving it into CgRPC. 9 years ago
README.md f3926c5c6a Change access level for generated classes and methods from "public" to "internal". 8 years ago
SwiftGRPC-incomplete.podspec 82b3a928d5 Rename podspec to clarify its status. 9 years ago
vendor-boringssl.sh 220cc3fe29 Update vendoring scripts and build configuration for examples for new vendored gRPC Core. 9 years ago
vendor-grpc.sh 220cc3fe29 Update vendoring scripts and build configuration for examples for new vendored gRPC Core. 9 years ago

README.md

Build Status

Swift gRPC

This repository contains an experimental Swift gRPC API and code generator.

It is intended for use with Apple's swift-protobuf support for Protocol Buffers. Both projects contain code generation plugins for protoc, Google's Protocol Buffer compiler, and both contain libraries of supporting code that is needed to build and run the generated code.

APIs and generated code is provided for both gRPC clients and servers, and can be built either with Xcode or the Swift Package Manager. Support is provided for all four gRPC API styles (Unary, Server Streaming, Client Streaming, and Bidirectional Streaming) and connections can be made either over secure (TLS) or insecure channels.

The Echo example provides a comprehensive demonstration of currently-supported features.

Swift Package Manager builds may also be made on Linux systems. Please see DOCKER.md and LINUX.md for details.

gRPC dependencies are vendored

Swift gRPC includes vendored copies of the gRPC core library and BoringSSL, an OpenSSL fork that is used by the gRPC Core. These are built automatically in Swift Package Manager builds.

Usage

The recommended way to use Swift gRPC is to first define an API using the Protocol Buffer language and then use the Protocol Buffer Compiler and the Swift Protobuf and gRPC-Swift plugins to generate the necessary support code.

Getting the dependencies

Binary releases of protoc, the Protocol Buffer Compiler, are available on GitHub.

To build the plugins, run make in the Plugins directory. This uses the Swift Package Manager to build both of the necessary plugins: protoc-gen-swift, which generates Protocol Buffer support code and protoc-gen-swiftgrpc, which generates gRPC interface code.

Using the plugins

To use the plugins, protoc and both plugins should be in your search path. Invoke them with commands like the following:

protoc <your proto files> \
    --swift_out=. \
    --swiftgrpc_out=.

By convention the --swift_out option invokes the protoc-gen-swift plugin and --swiftgrpc_out invokes protoc-gen-swiftgrpc.

Building your project

Most grpc-swift development is done with the Swift Package Manager. For usage in Xcode projects, we rely on the swift package generate-xcodeproj command to generate an Xcode project for the grpc-swift core libraries.

The top-level Makefile uses the Swift Package Manager to generate an Xcode project for the SwiftGRPC package:

$ make

This will create SwiftGRPC.xcodeproj, which you should add to your project, along with setting build dependencies on BoringSSL, CgRPC, and gRPC. Due to present limitations in Package Manager configuration, the libz dependency is not included in the generated Xcode project. If you get build errors about missing symbols such as _deflate, _deflateEnd, etc., you can fix them by adding libz.tbd to the Link Binary With Libraries build step of the CgRPC target.

Please also note that your project will need to include the SwiftProtobuf.xcodeproj from Swift Protobuf and the source files that you generated with protoc and the plugins.

Please see Echo for a working Xcode-based example and file issues if you find any problems.

Low-level gRPC

While the recommended way to use gRPC is with Protocol Buffers and generated code, at its core gRPC is a powerful HTTP/2-based communication system that can support arbitrary payloads. As such, each gRPC library includes low-level interfaces that can be used to directly build API clients and servers with no generated code. For an example of this in Swift, please see the Simple example.

Having build problems?

grpc-swift depends on Swift, Xcode, and swift-proto. We are currently testing with the following versions:

  • Xcode 8.3.2 (8E2002)
  • Swift 3.1 (swiftlang-802.0.53 clang-802.0.42)
  • swift-protobuf 0.9.901

License

grpc-swift is released under the same license as gRPC, repeated in LICENSE.

Contributing

Please get involved! See our guidelines for contributing.