Repository navigation
Opt out of swift-protobuf default traits - #71
Merged
gjcairo merged 6 commits intoOct 28, 2026
Merged
Conversation
The swift-protobuf dependency took the default trait set, which includes `BinaryDelimitedStreams`. That trait gates the only part of the SwiftProtobuf module that imports full Foundation, for InputStream and OutputStream in BinaryDelimited.swift. SwiftPM unions trait requests across the dependency graph, so this re-enabled the trait for every package in any build including grpc-swift-extras, overriding packages that had deliberately opted out. grpc-swift-2 and grpc-swift-protobuf already pass `traits: []` for this reason; this brings grpc-swift-extras in line. Nothing here uses BinaryDelimited or the FieldMaskUtilities-gated APIs, so there is no functional change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
|
gjcairo
requested changes
Oct 21, 2026
| .package( | ||
| url: "https://github.com/apple/swift-protobuf.git", | ||
| from: "1.31.0" | ||
| from: "1.31.0", |
Collaborator
There was a problem hiding this comment.
We should bump the swift-protobuf version here; things may still build fine if SPM resolves to anything over 1.36.0 but traits were introduced in 1.36.0 so we shouldn't keep 1.31.0 here as it can cause issues.
Let's bump it to the latest minor while we're at it, 1.39.0.
sachinsharma3191
added a commit
to sachinsharma3191/swift-temporal-sdk
that referenced
this pull request
Oct 21, 2026
`BinaryDelimited.swift` is the only file in the SwiftProtobuf module that imports full Foundation, for InputStream and OutputStream, and swift-protobuf already gates it behind the `BinaryDelimitedStreams` trait. The trait is enabled by default, so the import is opt-out rather than unconditional. The SDK uses neither BinaryDelimited nor the FieldMaskUtilities-gated APIs, so nothing is lost by opting out. The trait landed in swift-protobuf 1.36.0, which is already the declared minimum, so no version bump is needed. This alone does not clear the linkage test: SwiftPM unions trait requests across the dependency graph, and grpc-swift-extras still takes the defaults, which re-enables the trait for every package in the build. That is fixed upstream in grpc/grpc-swift-extras#71; this change is what makes the opt-out effective once that ships. Signed-off-by: Sachin Sharma <sachinsharma31261@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Traits were introduced in swift-protobuf 1.36.0, so declaring `traits: []` against a 1.31.0 floor was inconsistent even though SPM resolved higher in practice. Bump to 1.39.0, the latest minor, matching grpc-swift-protobuf. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gjcairo
reviewed
Oct 22, 2026
| .package( | ||
| url: "https://github.com/apple/swift-protobuf.git", | ||
| from: "1.31.0" | ||
| // Traits were introduced in 1.36.0; 1.39.0 is the latest minor. |
Collaborator
There was a problem hiding this comment.
Please remove this comment, it's irrelevant and will become stale.
Contributor
Author
There was a problem hiding this comment.
Sure let me remove it and address other changes as well
gjcairo
reviewed
Oct 23, 2026
| url: "https://github.com/apple/swift-protobuf.git", | ||
| // Traits were introduced in 1.36.0; 1.39.0 is the latest minor. | ||
| from: "1.39.0", | ||
| // Opt-out of default traits to avoid pulling in full Foundation from `BinaryDelimitedStreams` |
Collaborator
There was a problem hiding this comment.
This comment was useful, I was only referring to the version comment, can you add this one back please.
FranzBusch
approved these changes
Oct 27, 2026
Generated code updates reflect changes from grpc-swift-2 with swift-protobuf 1.39.0 compatibility, including improvements to documentation strings.
gjcairo
approved these changes
Oct 28, 2026
gjcairo
enabled auto-merge (squash)
October 28, 2026 09:59
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.
Motivation
The
swift-protobufdependency here takes the default trait set, which includesBinaryDelimitedStreams. That trait gatesBinaryDelimited.swift— the only file in theSwiftProtobufmodule that imports fullFoundation, forInputStreamandOutputStream.SwiftPM unions trait requests across the dependency graph, so taking the defaults here
re-enables the trait for every package in a build that includes
grpc-swift-extras,including ones that have deliberately opted out.
grpc-swift-2already passestraits: [], andgrpc-swift-protobufdoes too with a comment naming this exact reason.The practical effect: a downstream package cannot prove it avoids linking
libFoundation.soon Linux while depending ongrpc-swift-extras. I ran into this onapple/swift-temporal-sdk#166,
which adds a Foundation-linkage CI check. With
grpc-swift-extrasopted out,-DBinaryDelimitedStreamsdisappears from the build plan; without it, the opt-out in thatpackage has no effect.
Modifications
Add
traits: []to theswift-protobufdependency, matching the two sibling repositories.Result
No functional change. Nothing in
grpc-swift-extrasusesBinaryDelimitedor theFieldMaskUtilities-gated APIs, andswift build --build-testspasses with the traitsdisabled. Downstream packages can now opt out effectively.