Beagle gRPC for iOS

This framework provides a client to communicate with Beagle using gRPC.

Beagle gRPC available at CocoaPods

Supported Platforms

Beagle gRPC’s platform support is identical to the platform support of Beagle. Note that Beagle gRPC uses gRPC Swift and requires Swift to be version 5.2 or higher.

NetworkClientGRPC

This class implements the NetworkClient protocol using gRPC. When creating your NetworkClientGRPC you have to provide the following parameters:

ParameterDescriptionRequired
grpcAddressAddress of the gRPC server. The host and port specified here will be used to create the gRPC connection channel. The request URL must have this parameter as prefix or the request will be delegated to the customHttpClient.
customHttpClientA fallback NetworkClient to handle non gRPC requests.
defaultCallOptionsDefault values to be used in every gRPC request, for instance, set static headers or define request time limit. Check gRPC Swift for all available options.
interceptorsA factory providing interceptors for each RPC. Interceptors allow request and response parts to be observed, mutated or dropped as necessary.

How to use Beagle gRPC in your iOS project

Add the dependency to your Podfile

pod 'BeagleGRPC'

After adding Beagle gRPC as a dependency in your project, you can create a NetworkClientGRPC and set it in your Beagle.dependencies.

import Beagle
import BeagleGRPC

let dependencies = BeagleDependencies()
Beagle.dependencies = dependencies

let baseUrl = "http://0.0.0.0:50051"
dependencies.networkClient = NetworkClientGRPC(
    grpcAddress: baseUrl,
    customHttpClient: nil
)
dependencies.urlBuilder = UrlBuilder(
  baseUrl: URL(string: baseUrl)
)

Now you are ready to connect to your gRPC server.

BeagleScreenViewController(.remote(.init(url: "/home")))