{"id":19943135,"url":"https://github.com/cats-oss/grpc-swift-client","last_synced_at":"2025-08-05T09:05:48.780Z","repository":{"id":33084563,"uuid":"145315865","full_name":"cats-oss/grpc-swift-client","owner":"cats-oss","description":":repeat: Client-side library that depends on SwiftGRPC which is a library of gRPC written in Swift.","archived":false,"fork":false,"pushed_at":"2024-02-09T00:35:32.000Z","size":202,"stargazers_count":50,"open_issues_count":3,"forks_count":7,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-07-21T07:32:33.351Z","etag":null,"topics":["client-side","grpc","ios","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cats-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"Support Files/SwiftGRPCClient-Carthage.xcconfig","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-19T15:40:49.000Z","updated_at":"2025-01-03T11:16:45.000Z","dependencies_parsed_at":"2025-06-03T21:41:02.520Z","dependency_job_id":"c6e17419-187e-415b-9674-88490c7d9feb","html_url":"https://github.com/cats-oss/grpc-swift-client","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/cats-oss/grpc-swift-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cats-oss%2Fgrpc-swift-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cats-oss%2Fgrpc-swift-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cats-oss%2Fgrpc-swift-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cats-oss%2Fgrpc-swift-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cats-oss","download_url":"https://codeload.github.com/cats-oss/grpc-swift-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cats-oss%2Fgrpc-swift-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268866549,"owners_count":24320276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-side","grpc","ios","swift"],"created_at":"2024-11-13T00:15:29.761Z","updated_at":"2025-08-05T09:05:48.679Z","avatar_url":"https://github.com/cats-oss.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift gRPC Client\n\n[![Version](https://img.shields.io/cocoapods/v/SwiftGRPCClient.svg?style=flat)](http://cocoadocs.org/docsets/SwiftGRPCClient)\n[![License](https://img.shields.io/cocoapods/l/SwiftGRPCClient.svg?style=flat)](http://cocoadocs.org/docsets/SwiftGRPCClient)\n[![Platform](https://img.shields.io/cocoapods/p/SwiftGRPCClient.svg?style=flat)](http://cocoadocs.org/docsets/SwiftGRPCClient)\n\nClient-side library that depends on [SwiftGRPC](https://github.com/grpc/grpc-swift) which is a library of [gRPC](https://grpc.io/) written in Swift. Basically it is used the function of `Core` part of `SwiftGRPC`, but it is made to make client implementation easier. \n\n---\n:warning: **WARNING :** If there is the breaking change in SwiftGRPC, this library may not be updatable.\n\n---\n\nThe following two modules are included.\n\n#### SwiftGRPCClient\nIt is a plugin to use when running at runtime. Link to the application or framework.\n\n#### protoc-gen-swiftgrpc-client\nIt is a [Protocol Buffer's](https://github.com/apple/swift-protobuf) plugin for creating the functions necessary to use `SwiftGRPCClient`. Use `protoc` to generate `.swift` from `.proto`.\n\n## SwiftGRPCClient\n\nIf you use `SwiftGRPC`, you can do `Unary` connection using generated `protocol` or `struct` as follows.\n\n```swift\nlet service = Echo_EchoServiceClient(address: \"YOUR_SERVER_ADDRESS\")\nvar requestMessage = Echo_EchoRequest()\nrequestMessage.text = \"message\"\n_ = try? service.get(requestMessage) { responseMessage, callResult in\n}\n```\n\nThe `get` method above can get a `message` by sending arbitrary `message`, but with this method you can not get the information of the logged-in user. For example, if you want to get user information, you will need to prepare the following methods.\n\n```swift\nvar requestUser = Example_UserRequest()\nrequestUser.id = \"user_id\"\n_ = try? service.getUser(requestUser) { responseUser, callResult in\n}\n```\n\nIn this way, when connecting using a certain request, a special method is required to execute the request.\n\nWith `SwiftGRPCClient`, `data` is the only method to make a `Unary` request.\n\n```swift\nlet session = Session(address: \"YOUR_SERVER_ADDRESS\")\nsession.stream(with: EchoUnaryRequest(text: \"message\"))\n    .data { result in\n    }\n```\n\nIt is possible to get the user's login information just by changing the request.\n\n```swift\nsession.stream(with: GetUserRequest(id: \"user_id\"))\n    .data { result in\n    }\n```\n\nSee also [SwiftGRPCClient](./Sources/SwiftGRPCClient/README.md) document.\n\n### Requirements\n\n- Swift 5.0\n- SwiftGRPC 0.9.1\n\n### How to Install\n\n#### CocoaPods\n\nAdd the following to your `Podfile`:\n\n```ruby\npod 'SwiftGRPCClient'\n```\n\n## protoc-gen-swiftgrpc-client\n\n`protoc-gen-swiftgrpc-client` is a plugin for [Protocol Buffers](https://github.com/apple/swift-protobuf). It automatically defines requests, responses and methods used when connecting using `SwiftGRPCClient`.\n\nSee also [protoc-gen-swiftgrpc-client](./Sources/protoc-gen-swiftgrpc-client/README.md) document.\n\n### Requirements\n\n- Swift 5.0\n- SwiftProtobuf 1.5.0\n\n### How to get plugin\n\nExecute the following command.\n\n```\n$ make gen\n```\n\n### Explain generated code\n\nAs an example, prepare the following `.proto`.\n\n```protobuf\nsyntax = \"proto3\";\n\npackage echo;\n\nservice Echo {\n    rpc Get(EchoRequest) returns (EchoResponse) {}\n}\n\nmessage EchoRequest {\n    string text = 1;\n}\n\nmessage EchoResponse {\n    string text = 1;\n}\n```\n\n`protoc` creates `.swift` file.\n\n```swift\n// MARK: - Echo Request Method\nenum Echo_EchoMethod: String, CallMethod {\n    case get = \"Get\"\n\n    static let service = \"echo.Echo\"\n}\n\n// MARK: - Echo_Echo Get Request\nprotocol _Echo_EchoGetRequest {\n    typealias InputType = Echo_EchoRequest\n    typealias OutputType = Echo_EchoResponse\n}\n\nprotocol Echo_EchoGetRequest: _Echo_EchoGetRequest, UnaryRequest {}\n\nextension Echo_EchoGetRequest {\n    var method: CallMethod {\n        return Echo_EchoMethod.get\n    }\n}\n```\n\n\nDefine the `Request` object using `protocol` in the generated `.swift`.\n\n```swift\nstruct EchoGetRequest: Echo_EchoGetRequest {\n    var request = Echo_EchoRequest()\n\n    init(text: String) {\n        request.text = text\n    }\n}\n```\n\n## LICENSE\n\nUnder the MIT license. See [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcats-oss%2Fgrpc-swift-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcats-oss%2Fgrpc-swift-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcats-oss%2Fgrpc-swift-client/lists"}