fix: update Swift protobuf codegen to match SDK runtime - #2052
Merged
Merged
Conversation
protoc-gen-swift was pinned to 1.22.0 while stream-video-swift links SwiftProtobuf 1.38.1, so every regeneration emitted code that fails Swift 6 builds and had to be hand-patched afterwards: - `static var allCases` instead of `static let` (concurrency-safety warning) - `_StorageClass` without Sendable handling (the iOS SDK patched this by hand in its Swift 6 migration) - deprecated `init(serializedData:)` instead of `init(serializedBytes:)` Pin the plugin to 1.38.1 via a new PROTO_SWIFT_VERSION in versions.sh, alongside the other pinned tool versions. 1.38.1 emits `nonisolated struct ...: @unchecked Sendable` on messages and `static nonisolated(unsafe) let defaultInstance`, so the hand-patched `_StorageClass: @unchecked Sendable` is no longer needed. The Swift twirp template had also drifted from what the iOS SDK maintains by hand on top of the generated file. Bring it in line: retry handling via HTTPConfig, `Response: ProtoModelResponse` with `hasError` checks, the X-Stream-Client header, `serializedBytes`, and 4-space indentation. Verified by regenerating video/sfu with the new plugin and template and building StreamVideo for iOS: no errors, no warnings from generated code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
tbarbugli
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
protoc-gen-swiftis pinned to 1.22.0 (install.sh), butstream-video-swiftlinks SwiftProtobuf 1.38.1. Every regeneration therefore emitted code that fails Swift 6 builds, and the iOS team hand-patched it afterwards — patches that were wiped by the next regen:static var allCasesinstead ofstatic let→ "static property is not concurrency-safe"_StorageClasswith no Sendable handling → hand-patched in the iOS SDK's Swift 6 migrationinit(serializedData:)instead ofinit(serializedBytes:)Separately, the Swift twirp template had drifted badly from what the iOS SDK maintains by hand on top of the generated
signal.twirp.swift— so those edits also had to be re-applied every time.Changes
versions.sh— newPROTO_SWIFT_VERSION=1.38.1, alongside the other pinned tool versions, with a note that it must track the SwiftProtobuf runtime the consuming SDKs link.install.sh— use that variable instead of the hardcoded1.22.0.tools/protoc-gen-swift-twirp/generator/template.goswift— brought in line with the hand-maintained client: retry handling viaHTTPConfig,Response: ProtoModelResponsewithhasErrorchecks, theX-Stream-Clientheader,serializedBytes, and 4-space indentation.1.38.1 emits
nonisolated struct ...: @unchecked Sendableon messages andstatic nonisolated(unsafe) let defaultInstance, so Swift 6 is satisfied at the struct level and the hand-patched_StorageClass: @unchecked Sendableis no longer needed.Verification
Built
protoc-gen-swift1.38.1 and the updated twirp plugin locally, regeneratedvideo/sfu, dropped the output intostream-video-swift, and builtStreamVideofor iOS Simulator: BUILD SUCCEEDED, zero errors and zero warnings from generated code. Diffing the newsignal.twirp.swiftagainst the hand-maintained one shows no semantic differences — onlysendMetrics(genuinely new in the proto) andupdate(userToken:)moving below the generated methods.Follow-ups for the iOS SDK (not in this PR)
SendMetricsResponseis an empty message with noerrorfield, so it can't satisfyErrorProvidinglike the other responses. It needs an explicit conformance inProtoModel.swiftbefore the regenerated code compiles.ErrorProvidinglist is hand-maintained, so every new RPC breaks the iOS build until someone adds a line. Worth considering having the template generate these conformances.Rollout
Both changed files are baked into the Docker image at build time (
DockerfiledoesCOPY . /home/+RUN ./install.sh, and the template isgo:embeded). So this needs to land onmain→docker-image.ymlrebuildsghcr.io/getstream/protobuf-generate:latest→Scripts/generateCode.shon the SDK side picks it up. Anyone with an existing/opt/.protocinstall must re-runinstall.shto get the new plugins locally.🤖 Generated with Claude Code