Нет описания

George Barnett 6cab35e471 Bump version number to 1.10.0 (#1481) 3 лет назад
.github 9ccefbe274 Add nightly 5.7 CI (#1438) 3 лет назад
Examples 703d351545 Remove Cocoapods script and references (#1439) 3 лет назад
FuzzTesting edcd6b944c Raise minimum supported Swift version to 5.4 (#1397) 3 лет назад
Performance 20bba23f4a Add GRPC and protobuf SPM plugins to QPSBenchmark (#1475) 3 лет назад
Plugins 964a8775f7 Add SPM plugin for GRPC code generation (#1474) 3 лет назад
Sources 6cab35e471 Bump version number to 1.10.0 (#1481) 3 лет назад
Tests babcff1f9d Provide an error when cancelling async writer (#1456) 3 лет назад
dev 1d968f50cf Bump version number to 1.4.2 (#1280) 4 лет назад
docs 703d351545 Remove Cocoapods script and references (#1439) 3 лет назад
scripts f624b0022a Prepare for DocC (#1467) 3 лет назад
.gitignore f6c6762fab Add a unary server benchmark (#1074) 5 лет назад
.gitmodules 63c6acfa40 Move CgRPC, gRPC, and QuickProto to "Sources" directory and add new top-level Package.swift. 9 лет назад
.swiftformat 80055e59b5 Update formatter 3 лет назад
AUTHORS 0aa90a79ee Relicense to Apache 2, change owners to "the gRPC Authors". 8 лет назад
CODE-OF-CONDUCT.md 5ef0870727 Add/update GOVERNANCE.md, CODE-OF-CONDUCT.md and CONTRIBUTING.md (#595) 6 лет назад
CONTRIBUTING.md 5ef0870727 Add/update GOVERNANCE.md, CODE-OF-CONDUCT.md and CONTRIBUTING.md (#595) 6 лет назад
GOVERNANCE.md 5ef0870727 Add/update GOVERNANCE.md, CODE-OF-CONDUCT.md and CONTRIBUTING.md (#595) 6 лет назад
LICENSE 6dde0518ca Revert to Apache 2.0 license verbatim [skip ci] (#504) 6 лет назад
MAINTAINERS.md e0c70ce6f8 Add MAINTAINERS.md. (#564) (#576) 6 лет назад
Makefile c5578d48df Add a codegen option to allow stub names to not have their first character lowercased (#1123) 4 лет назад
NOTICES.txt 31003a1593 Add allocation counting tests (#1150) 4 лет назад
PATENTS 36f2bde28e Add PATENTS declaration 9 лет назад
Package.swift 1579a9c082 Fix preconcurrency warnings (#1480) 3 лет назад
Package@swift-5.4.swift 6639e45c1f Remove warnings from Package.swift (#1469) 3 лет назад
Package@swift-5.5.swift 6639e45c1f Remove warnings from Package.swift (#1469) 3 лет назад
README.md a0d57279af Add index docc page and fix comment links (#1473) 3 лет назад
SECURITY.md 7fbc418471 Add a security policy. (#1193) 4 лет назад

README.md

CI Latest Version

gRPC Swift

This repository contains a gRPC Swift API and code generator.

It is intended for use with Apple's SwiftProtobuf 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.

Versions

gRPC Swift has recently been rewritten on top of SwiftNIO as opposed to the core library provided by the gRPC project.

Version Implementation Branch protoc Plugin Support
1.x SwiftNIO main protoc-gen-grpc-swift Actively developed and supported
0.x gRPC C library cgrpc protoc-gen-swiftgrpc No longer developed; security fixes only

The remainder of this README refers to the 1.x version of gRPC Swift.

Supported Platforms

gRPC Swift's platform support is identical to the platform support of Swift NIO.

The earliest supported Swift version for gRPC Swift 1.8.x and newer is 5.4. For 1.7.x and earlier the oldest supported Swift version is 5.2.

Versions of clients and services which are use Swift's Concurrency support are available from gRPC Swift 1.8.0 and require Swift 5.6 and newer.

Getting gRPC Swift

There are two parts to gRPC Swift: the gRPC library and an API code generator.

Getting the gRPC library

Swift Package Manager

The Swift Package Manager is the preferred way to get gRPC Swift. Simply add the package dependency to your Package.swift:

dependencies: [
  .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.9.0")
]

...and depend on "GRPC" in the necessary targets:

.target(
  name: ...,
  dependencies: [.product(name: "GRPC", package: "grpc-swift")]
]
Xcode

From Xcode 11 it is possible to add Swift Package dependencies to Xcode projects and link targets to products of those packages; this is the easiest way to integrate gRPC Swift with an existing xcodeproj.

Manual Integration

Alternatively, gRPC Swift can be manually integrated into a project:

  1. Build an Xcode project: swift package generate-xcodeproj,
  2. Add the generated project to your own project, and
  3. Add a build dependency on GRPC.

Getting the protoc Plugins

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

To build the plugins, run make plugins in the main 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-grpc-swift, which generates gRPC interface code.

To install these plugins, just copy the two executables (protoc-gen-swift and protoc-gen-grpc-swift) that show up in the main directory into a directory that is part of your PATH environment variable. Alternatively the full path to the plugins can be specified when using protoc.

Homebrew

The plugins are available from homebrew and can be installed with:

    $ brew install swift-protobuf grpc-swift

Examples

gRPC Swift has a number of tutorials and examples available. They are split across two directories:

  • /Sources/Examples contains examples which do not require additional dependencies and may be built using the Swift Package Manager.
  • /Examples contains examples which rely on external dependencies or may not be built by the Swift Package Manager (such as an iOS app).

Some of the examples are accompanied by tutorials, including:

  • A quick start guide for creating and running your first gRPC service.
  • A basic tutorial covering the creation and implementation of a gRPC service using all four call types as well as the code required to setup and run a server and make calls to it using a generated client.
  • An interceptors tutorial covering how to create and use interceptors with gRPC Swift.

Documentation

The docs directory contains documentation, including:

Security

Please see SECURITY.md.

License

gRPC Swift is released under the same license as gRPC, repeated in LICENSE.

Contributing

Please get involved! See our guidelines for contributing.