### Build and Run Route Guide Server Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/route-guide/README.md Builds and starts the Route Guide server using the Swift Package Manager. Ensure 'protoc' is in your PATH or set PROTOC_PATH. ```console $ PROTOC_PATH=$(which protoc) swift run route-guide serve server listening on [ipv4]127.0.0.1:31415 ``` -------------------------------- ### Running the Detailed Error Example Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/error-details/README.md Build and run the command-line tool to observe detailed error reporting from a gRPC service. This example requires `protoc` to be installed and in your PATH. ```console $ PROTOC_PATH=$(which protoc) swift run Error code: resourceExhausted Error message: The greeter has temporarily run out of greetings. Error details: - Localized message (en-GB): Out of enthusiasm. The greeter is having a cup of tea, try again after that. - Localized message (en-US): Out of enthusiasm. The greeter is taking a coffee break, try again later. - Help links: - https://en.wikipedia.org/wiki/Caffeine (A Wikipedia page about caffeine including its properties and effects.) ``` -------------------------------- ### Serve Echo-Metadata Server Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo-metadata/README.md Starts the echo-metadata server. Ensure 'protoc' is in your PATH. ```console PROTOC_PATH=$(which protoc) swift run echo-metadata serve Echo-Metadata listening on [ipv4]127.0.0.1:1234 ``` -------------------------------- ### Run GRPCServer and Get Listening Address Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Demonstrates how to start the GRPCServer and concurrently retrieve its listening address. This pattern is useful for dynamically configuring clients or for logging server status. ```swift try await withThrowingDiscardingTaskGroup { group in group.addTask { try await server.serve() } if let address = try await server.listeningAddress { print("Listening on \(address)") } } ``` -------------------------------- ### Build and Run Service Lifecycle CLI Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/service-lifecycle/README.md Builds and runs the service-lifecycle command-line tool. Ensure `protoc` is installed and in your PATH. This command starts an in-process gRPC client and server. ```console PROTOC_PATH=$(which protoc) swift run service-lifecycle Здравствуйте, request-1! नमस्ते, request-2! 你好, request-3! Bonjour, request-4! Olá, request-5! Hola, request-6! Hello, request-7! Hello, request-8! नमस्ते, request-9! Hello, request-10! ``` -------------------------------- ### Route Guide CLI Help Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/route-guide/README.md Displays the available subcommands and options for the Route Guide command-line tool. This helps in understanding the different RPC functionalities that can be invoked. ```console $ PROTOC_PATH=$(which protoc) swift run route-guide --help USAGE: route-guide OPTIONS: -h, --help Show help information. SUBCOMMANDS: serve Starts a route-guide server. get-feature Gets a feature at a given location. list-features List all features within a bounding rectangle. record-route Records a route by visiting N randomly selected points and prints a summary of it. route-chat Visits a few points and records a note at each, and prints all notes previously recorded at each point. See 'route-guide help ' for detailed help. ``` -------------------------------- ### Run gRPC Hello World Server Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/hello-world/README.md Build and run the gRPC server using the command-line interface. Ensure `protoc` is installed and in your PATH. ```console $ PROTOC_PATH=$(which protoc) swift run hello-world serve Greeter listening on [ipv4]127.0.0.1:31415 ``` -------------------------------- ### Initialize GRPCServer with HTTP/2 Transport Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Example of initializing a GRPCServer with the HTTP/2 transport, specifying host, port, and TLS configuration. This server setup is suitable for production environments. ```swift let server = GRPCServer( transport: .http2NIOPosix( // Configure the host and port to listen on. address: .ipv4(host: "127.0.0.1", port: 1234), // Configure TLS here, if your're using it. transportSecurity: .plaintext, config: .defaults { // Change any of the default config in here. } ), // List your services here: services: [] ) // Start the server. try await server.serve() ``` -------------------------------- ### Describe Service Method with grpcurl Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/reflection-server/README.md Use `grpcurl` to get detailed information about a specific method within a service. ```bash $ grpcurl -plaintext 127.0.0.1:31415 describe echo.Echo.Get echo.Echo.Get is a method: // Immediately returns an echo of a request. rpc Get ( .echo.EchoRequest ) returns ( .echo.EchoResponse ); ``` -------------------------------- ### Client Unary Request (get) Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo-metadata/README.md Makes a unary 'get' request, sending a message and metadata. Displays request and response metadata and messages. ```console PROTOC_PATH=$(which protoc) swift run echo-metadata get --message "hello" get → metadata: [("echo-message", "hello")] get → message: hello get ← initial metadata: [("echo-message", "hello")] get ← message: hello get ← trailing metadata: [("echo-message", "hello")] ``` -------------------------------- ### Make Unary 'Get' Request Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo/README.md Execute a unary 'Get' request against the echo server using the CLI. The message sent is echoed back. ```console $ PROTOC_PATH=$(which protoc) swift run echo get --message "Hello" get → Hello get ← Hello ``` -------------------------------- ### Initialize gRPC Client with HTTP/2 Transport Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Example of initializing a gRPC client using the HTTP/2 NIO Posix transport with TLS enabled and DNS resolution for the target host. ```swift try await withGRPCClient( transport: .http2NIOPosix( target: .dns(host: "example.com"), transportSecurity: .tls, ) ) { client in // ... } ``` -------------------------------- ### Download v1-to-v2 Migration Script Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Download the migration script to automate several migration steps. Ensure you have curl installed. ```shell curl https://raw.githubusercontent.com/grpc/grpc-swift/refs/heads/main/dev/v1-to-v2/v1_to_v2.sh -o v1_to_v2 ``` -------------------------------- ### Build and Run Reflection Server Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/reflection-server/README.md Build and execute the reflection server using the Swift Package Manager. ```bash $ swift run reflection-server Reflection server listening on [ipv4]127.0.0.1:31415 ``` -------------------------------- ### Run Echo Server Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo/README.md Build and run the echo server using the command-line interface. Ensure 'protoc' is in your PATH. ```console $ PROTOC_PATH=$(which protoc) swift run echo serve Echo listening on [ipv4]127.0.0.1:1234 ``` -------------------------------- ### List Services with grpcurl Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/reflection-server/README.md Use `grpcurl` to query the reflection service and list all available services on the server. ```bash $ grpcurl -plaintext 127.0.0.1:31415 list echo.Echo ``` -------------------------------- ### CLI Help Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo-metadata/README.md Displays help information for the echo-metadata CLI tool. Ensure 'protoc' is in your PATH. ```console PROTOC_PATH=$(which protoc) swift run echo-metadata --help ``` -------------------------------- ### Run gRPC Swift Benchmarks Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Benchmarks.md Execute the benchmark suite from the command line within the Performance/Benchmarks directory. ```bash swift package benchmark ``` -------------------------------- ### Make Migration Script Executable Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Make the downloaded v1_to_v2 script executable before use. This is a prerequisite for running the script. ```shell chmod +x v1_to_v2 ``` -------------------------------- ### Send gRPC Hello World Request with Name Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/hello-world/README.md Send a 'greet' request to the gRPC service, specifying a name to be included in the greeting. This demonstrates passing parameters to the service. ```console $ PROTOC_PATH=$(which protoc) swift run hello-world greet --name "PanCakes 🐶" Hello, PanCakes 🐶 ``` -------------------------------- ### Send Basic gRPC Hello World Request Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/hello-world/README.md Send a basic 'greet' request to the gRPC service using the command-line tool. This will return a default greeting. ```console $ PROTOC_PATH=$(which protoc) swift run hello-world greet Hello, stranger ``` -------------------------------- ### Display CLI Help Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo/README.md View the help information for the echo command-line tool to understand available commands and options. ```console $ PROTOC_PATH=$(which protoc) swift run echo --help ``` -------------------------------- ### Clone Local Copy of gRPC Swift 1.x Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Create a local copy of gRPC Swift 1.x within your project's 'LocalPackages' directory using the migration script. This is necessary because Swift packages cannot depend on two different major versions of the same package simultaneously. ```shell mkdir LocalPackages && ./v1_to_v2 clone-v1 LocalPackages ``` -------------------------------- ### Generate Protobuf Descriptor Set Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/reflection-server/README.md Use `protoc` to create a descriptor set file, including source information and dependencies, from a Protobuf definition. ```bash protoc --descriptor_set_out=path/to/output.pb path/to/input.proto \ --include_source_info \ --include_imports ``` -------------------------------- ### Find Generated gRPC Files (build plugin) Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Locate generated gRPC Swift files within the `.build/plugins/outputs` directory when using the build plugin. ```sh find .build/plugins/outputs -name '*.grpc.swift' ``` -------------------------------- ### Generate Swift Protocol Buffers Messages Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec03-step03-gen-messages.txt Use the protoc compiler with the swift_out option to generate Swift code from a .proto file. Ensure the protoc-gen-swift plugin is in your PATH or specified directly. ```bash $ protoc --plugin=.build/debug/protoc-gen-swift \ -I Protos \ --swift_out=Sources/Generated \ Protos/route_guide.proto ``` -------------------------------- ### Rename Generated gRPC Files (protoc direct) Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Use the `v1_to_v2` script to rename `*.grpc.swift` files to `*.grpc.v1.swift` when generating gRPC code directly with protoc. ```sh ./v1_to_v2 rename-generated-files Sources/ ``` -------------------------------- ### Call Service Method with grpcurl Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/reflection-server/README.md Invoke a specific RPC method on the reflection server using `grpcurl`, providing request data and receiving a response. ```bash $ grpcurl -plaintext -d '{ "text": "Hello" }' 127.0.0.1:31415 echo.Echo.Get { "text": "Hello" } ``` -------------------------------- ### Update Build Plugin Manifest Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Replace the gRPC Swift 1.x and SwiftProtobuf build plugins with the 2.x plugin in your Swift package manifest. ```swift .target( ... plugins: [ .plugin(name: "GRPCProtobufGenerator", package: "grpc-swift-protobuf") ] ) ``` -------------------------------- ### Add gRPC Swift 2.x Target Dependencies Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Update target dependencies to use the products from gRPC Swift 2.x and its related libraries. Run 'swift build' again to verify your package still builds. ```swift .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"), ``` -------------------------------- ### Generate Swift gRPC Code Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec03-step04-gen-grpc.txt Use the protoc compiler with the grpc-swift plugin to generate Swift code for your gRPC services. Ensure the plugin is in your PATH or specified with its full path. The output directory should be set to where you want the generated Swift files to be placed. ```bash $ protoc --plugin=.build/debug/protoc-gen-grpc-swift-2 \ -I Protos \ --grpc-swift_out=Sources/Generated \ Protos/route_guide.proto ``` -------------------------------- ### gRPC-Swift Simple Service Protocol (Conceptual) Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Design.md Offers a simplified interface focusing only on message payloads, abstracting away metadata and complex streaming details. Note: This protocol is not yet implemented. ```swift protocol ServiceName.SimpleServiceProtocol: ServiceName.ServiceProtocol { func unaryRPC( request: InputName, context: ServerContext ) async throws -> OutputName func clientStreamingRPC( request: RPCAsyncSequence, context: ServerContext ) async throws -> OutputName func serverStreamingRPC( request: InputName, response: RPCWriter, context: ServerContext ) async throws func bidirectionalStreamingRPC( request: RPCAsyncSequence, response: RPCWriter, context: ServerContext ) async throws } ``` -------------------------------- ### Make Bidirectional Streaming 'Update' Request Source: https://github.com/grpc/grpc-swift-2/blob/main/Examples/echo/README.md Perform a bidirectional streaming 'Update' request against the echo server. Multiple messages can be sent and received. ```console $ PROTOC_PATH=$(which protoc) swift run echo update --message "Hello World" update → Hello update → World update ← Hello update ← World ``` -------------------------------- ### gRPC-Swift Higher-Level Client APIs Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Design.md Provides simplified client APIs that abstract away request creation. Unary RPCs become message-in, message-out. Bidirectional streaming uses separate closures for sending and receiving. ```swift extension ServiceName.ClientProtocol { func unaryRPC( _ message: InputName, metadata: Metadata = [:], options: CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (ClientResponse) async throws -> Result = { try $0.message } ) async throws -> Result where Result: Sendable { // ... } func clientStreamingRPC( metadata: Metadata = [:], options: CallOptions = .defaults, requestProducer: @Sendable @escaping (RPCWriter) async throws -> Void, onResponse handleResponse: @Sendable @escaping (ClientResponse) async throws -> Result = { try $0.message } ) async throws -> Result where Result: Sendable { // ... } func serverStreamingRPC( _ message: InputName, metadata: Metadata = [:], options: CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { // ... } func bidirectionalStreamingRPC( metadata: Metadata = [:], options: CallOptions = .defaults, requestProducer: @Sendable @escaping (RPCWriter) async throws -> Void, onResponse handleResponse: @Sendable @escaping (StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { // ... } } ``` -------------------------------- ### Swift Package Manifest for gRPC Swift Source: https://github.com/grpc/grpc-swift-2/blob/main/README.md Use this Swift Package manifest to integrate gRPC Swift v2.x with SwiftNIO transport and SwiftProtobuf serialization into your macOS project. ```swift // swift-tools-version: 6.0 import PackageDescription let package = Package( name: "Application", platforms: [.macOS("15.0")], dependencies: [ .package(url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0"), .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "2.0.0"), .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "2.0.0"), ], targets: [ .executableTarget( name: "Server", dependencies: [ .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), ] ) ] ) ``` -------------------------------- ### gRPC-Swift Client Protocol Extension with Defaults Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Design.md Extends the client protocol to provide default serializers, deserializers, and options. For single-response RPCs, it also defaults the response handler to extract the message. ```swift extension ServiceName.ClientProtocol { func unaryRPC( request: ClientRequest, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse) async throws -> R = { try $0.message } ) async throws -> R where R: Sendable { // ... } func clientStreamingRPC( request: StreamingClientRequest, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse) async throws -> R = { try $0.message } ) async throws -> R where R: Sendable { // ... } func serverStreamingRPC( request: ClientRequest, options: CallOptions = .defaults, _ body: @Sendable @escaping (StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { // ... } func bidirectionalStreamingRPC( request: StreamingClientRequest, options: CallOptions = .defaults, _ body: @Sendable @escaping (StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { // ... } } ``` -------------------------------- ### Declare New Client Property Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md When a generated client is a stored type, add a new computed property returning an instance of the 2.x client. Use `fatalError` as a placeholder until the implementation is complete. ```swift var client: Foo_Bar_Baz.Client { fatalError("TODO") } ``` -------------------------------- ### Update Package.swift for Local 1.x Dependency Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Modify your Package.swift manifest to use the local copy of gRPC Swift 1.x instead of the GitHub version. Update both the package dependency and target dependencies accordingly. Ensure your package still builds with 'swift build' after these changes. ```swift let package = Package( ... dependencies: [ .package(path: "LocalPackages/grpc-swift-v1") ], targets [ .executableTarget( name: "Application", dependencies [ ... .product(name: "GRPC", package: "grpc-swift-v1"), ... ] ) ] ... ) ``` -------------------------------- ### Add gRPC Swift 2.x Package Dependencies Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Add the necessary package dependencies for gRPC Swift 2.x and its related libraries. Ensure your package still builds with 'swift build' after adding these dependencies. ```swift .package(url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0"), .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "2.0.0"), .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "2.0.0"), ``` -------------------------------- ### Patch Service Code for Migration Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Use the `v1_to_v2` script to automatically apply transformations to service code files during migration, such as updating imports and type names. ```sh ./v1_to_v2 patch-service Sources/Server/Service.swift ``` -------------------------------- ### gRPC-Swift Client Protocol Definition Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Design.md Defines the core gRPC client methods for different RPC types, including unary, client streaming, server streaming, and bidirectional streaming. Each method requires explicit serializers, deserializers, and options. ```swift protocol ServiceName.ClientProtocol { func unaryRPC( request: ClientRequest, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (ClientResponse) async throws -> R ) async throws -> R where R: Sendable func clientStreamingRPC( request: StreamingClientRequest, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (ClientResponse) async throws -> R ) async throws -> R where R: Sendable func serverStreamingRPC( request: ClientRequest, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable func bidirectionalStreamingRPC( request: StreamingClientRequest, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable } ``` -------------------------------- ### gRPC-Swift Streaming Service Protocol Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Design.md Defines the most flexible, fully-streaming interface for a gRPC service. Use this when fine-grained control over metadata and streaming is required for each RPC type. ```swift protocol ServiceName.StreamingServiceProtocol { func unaryRPC( request: StreamingServerRequest, context: ServerContext ) async throws -> StreamingServerResponse // client-, server-, and bidirectional-streaming are exactly the same as // unary. } ``` -------------------------------- ### gRPC-Swift Regular Service Protocol Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Design.md Provides a higher-level API tailored to specific RPC types (unary, client-streaming, server-streaming, bidirectional-streaming). This is the most commonly used protocol for implementing gRPC services. ```swift protocol ServiceName.ServiceProtocol: ServiceName.StreamingServiceProtocol { func unaryRPC( request: ServerRequest, context: ServerContext ) async throws -> ServerResponse func clientStreamingRPC( request: StreamingServerRequest, context: ServerContext ) async throws -> ServerResponse func serverStreamingRPC( request: ServerRequest, context: ServerContext ) async throws -> StreamingServerResponse func bidirectionalStreamingRPC( request: StreamingServerRequest, context: ServerContext ) async throws -> StreamingServerResponse } ``` -------------------------------- ### Update Server Streaming RPC in Swift Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Migrates a server streaming RPC from gRPC Swift 1.x to 2.x. The 2.x version requires handling the response stream within a closure passed to the client method. ```swift func serverStreamingEcho(text: String, client: Echo_EchoAsyncClient) async throws { for try await reply in client.expand(.with { $0.text = text }) { print(reply.text) } } ``` ```swift func serverStreamingEcho(text: String, client: Echo_Echo.Client) async throws { try await client.expand(.with { $0.text = text }) { response in for try await reply in response.messages { print(reply.text) } } } ``` -------------------------------- ### Update Swift Tools Version and Platforms Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Increase the Swift tools version to 6.0 or higher and set the required deployment targets for gRPC Swift 2.x. Note that changing platforms is an API-breaking change. Verify your package still builds with 'swift build'. ```swift // swift-tools-version: 6.0 ``` ```swift let package = Package( name: "...", platforms: [ .macOS(.v15), .iOS(.v18), .tvOS(.v18), .watchOS(.v11), .visionOS(.v2), ], ... ) ``` -------------------------------- ### Update Client Streaming RPC in Swift Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Articles/Migration-guide.md Migrates a client streaming RPC from gRPC Swift 1.x to 2.x. The 2.x version requires providing messages within a closure passed to the client method. ```swift func clientStreamingEcho(text: String, client: Echo_EchoAsyncClient) async throws { let messages = makeAsyncSequenceOfMessages(text) let reply = try await client.collect(messages) print(reply.text) } ``` ```swift func clientStreamingEcho(text: String, client: Echo_Echo.Client) async throws { let reply = try await client.collect { request in for try await message in makeAsyncSequenceOfMessages(text) { request.write(message) } } print(reply.text) } ``` -------------------------------- ### Disable jemalloc for Xcode Source: https://github.com/grpc/grpc-swift-2/blob/main/Sources/GRPCCore/Documentation.docc/Development/Benchmarks.md Launch Xcode with jemalloc disabled using an environment variable, typically for profiling purposes. ```bash BENCHMARK_DISABLE_JEMALLOC=true xed . ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.