grpc / grpc-swift

The Swift language implementation of gRPC.
Apache License 2.0
2.05k stars 420 forks source link
grpc protocol-buffers swift swift-grpc

gRPC Swift

This repository contains a gRPC implementation for Swift. You can read more about gRPC on the gRPC project's website.

gRPC Swift v2.x is under active development on the main branch and takes full advantage of Swift's native concurrency features.

v1.x is still supported and maintained on the release/1.x branch.

Quick Start

The following snippet contains a Swift Package manifest to use gRPC Swift v2.x with the SwiftNIO based transport and SwiftProtobuf serialization:

// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "foo-package",
    platforms: [.macOS("15.0")],
    dependencies: [
        .package(url: "https://github.com/grpc/grpc-swift.git", from: "2.0.0-alpha.1"),
        .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "1.0.0-alpha.1"),
        .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "1.0.0-alpha.1"),
    ],
    targets: [
        .executableTarget(
            name: "bar-target",
            dependencies: [
                .product(name: "GRPCCore", package: "grpc-swift"),
                .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"),
                .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
            ]
        )
    ]
)