2901 Commits

Author SHA1 Message Date
Thomas Van Lenten f6506eaa86 version bump for a release (#2063) 1.38.0 2026-05-15 17:39:11 +00:00
Tony Allevato ac7ee45712 Add an experimental generator option to suppress field/enum case/message names. (#2062)
If you're only using binary format protos or protos as values in memory,
shedding the TextFormat/JSON support can be useful to reduce binary
size.
2026-05-15 10:22:13 -04:00
George Barnett 2f58de3712 Generate nonisolated code (#2055)
Motivation:

When setting the default actor isolation to 'MainActor', generated
protobuf code will fail to compile.

Modifications:

- Add 'nonisolated' to generated declaration
- Add a compile test

Result:

- Resolves https://github.com/apple/swift-protobuf/issues/1797
2026-05-13 16:53:23 +01:00
George Barnett d44ea38550 Add WKT import path directly to protoc binary (#2060)
Motivation:

The recent changes to the build plugin only add import paths to the
SwiftPM entrypoint. The Xcode plugin entrypoint doesn't have appropriate
support to add an import for the WKTs.

Another limitation of the current approach is that users building and
using `protoc` from the pacakge (i.e. `swift build --product protoc`)
won't get the WKT include paths.

This changes takes a different approach by rewriting the entrypoint to
protoc to unconditionally add the WKT include path. This means WKTs work
for the SwiftPM plugin, Xcode plugins, and when using `protoc` directly.
It also obviates the need for downstream pacakges depending on `protoc`
in their plugins (e.g. gRPC) to scan for the include paths in their
plugins.

Modifications:

- Add a new 'main.cc' which does what 'main_no_generators.cc' does but
  adds the WKT include path to the invocation.
- Remove 'main_no_generators.cc' and update the vendoring script to
  prune it out.
- Revert recent changes to the SwiftPM plugin which scanned for protobuf
  sources for the include path

Result:

WKTs work with protoc in more places
2026-05-12 15:50:05 +00:00
Thomas Van Lenten f9444132c7 Flip the order of the diff in test-plugin (#2059)
When this failed on CI the other day it looked a little odd as the "-"
lines were the ones that were the new state. So flip the order so the
"+" lines are how it should be generated vs. what is currently checked
in to the Reference directory. i.e. - the output becomes "the patch to
apply to reference" instead of the output being what would get applied
to the "generator".
2026-05-08 16:44:25 +00:00
George Barnett e45184eace Drop Swift 6 support (#2056)
Motivation:

Swift 6.0 has fallen out of our support policy.

Modifications:

- remove Package@swift-6.0.swift
- update various docs and examples
- drop Swift 6.0 from CI

Result:

Swift 6.0 is no longer supported
2026-05-07 14:51:28 -04:00
Franz Busch 3c93acf277 Support well known proto types in Swift PM plugin (#2044)
Fixes #1943 and supersedes #1979.

This PR adds support for well known types in the Swift PM plugin by
either:
- Looking for the types next to the binary when the env variable or a
direct protoc path is specified
- Looking for the source directory of our vendored protobuf repo

Co-authored-by: Thomas Van Lenten <thomasvl@google.com>
2026-05-07 08:42:52 -04:00
Thomas Van Lenten 3c8b0109b1 Use the fuzz options support to control encoding options. (#2049)
In looking at the code coverage on oss-fuzz, I realized the encoding
support never goes down paths related to options being not the default,
so go ahead and allow the existing options extraction to set those also,
so we're running everything possible to help look for bugs.

All but one of the options defaulted to "false", so since the fuzz
options parsing was ensuring the extra bits were zero, it is safe to
just add the option. The one that wasn't zero, we add a new "inverted"
bool so all saved cases remain valid.

This also gave us the change to control "partial" on binary decoding, so
wire that up also.

Lastly, while at it, increase the options logging so it is a little more
complete.
2026-05-05 10:16:24 -04:00
Thomas Van Lenten 19ff62e5ff Update protos from upstream. (#2047)
Using upstream commit 19d9cbf841f62227d3d349e944fc376dc9e0ba3f.
2026-05-04 16:37:45 +00:00
Thomas Van Lenten c1817627b5 Update FuzzTesting Package.swift. (#2037)
Now that https://github.com/google/oss-fuzz/pull/14342 has landed, we
can properly updated FuzzTesting/Package.swift to also be 6.x based.

This pulls over what @glbrntt's had attempted in #1913 but couldn't be
landed because of issues in 6.0/6.1, but now that we only do fuzz
testing on 6.2+ it is safe.

It also sets the explicit `traits` for SwiftProtobuf since the FieldMask
additions aren't needed.
2026-04-27 15:18:26 +00:00
Thomas Van Lenten 175311d9d0 Update proto files from upstream. (#2045)
Using upstream e82dcf85a5285fa3b172f9d875ec1c3820058cb4.
2026-04-27 10:49:35 -04:00
Thomas Van Lenten 81558271e2 Updated vendored dependencies (#2026)
protobuf: v34.1 (4b0c3aacf0657fbf38253b38918d3358dd4319ec)
  abseil:   76bb24329e8bf5f39704eb10d21b9a80befa7c81 tag:20250512.1

This was done by manually running the script and then looking at what
files got removed and added to figure out the Package*.swift changes.

Note: the script doesn't run on Sequoia without edits because it uses
some things in newer versions of python3 than what Apple bundles there.
1.37.0
2026-04-18 23:41:18 +00:00
Thomas Van Lenten 23627a751c Version bump for a release. (#2024) 2026-04-18 15:19:25 -07:00
Thomas Van Lenten 5ec9b50952 Add a cache for the recursive check to help improve performance. (#2034)
Also documented a lot more about how/why decisions are made.

Since the current algorithm stop as soon as it has found the first path
to recursion, this still isn't as optimal as possible. A truly optimal
solution would more completely evaluate the graph so there are fewer
places that need to repeat the work.
2026-04-17 16:56:19 -04:00
Thomas Van Lenten 5520082b16 Remove the 'echo' left from faking a successfull update. (#2031) 2026-04-16 13:57:27 +00:00
Thomas Van Lenten 7534b915b0 Prevent make reference from failing the protobuf & abseil updates. (#2029)
If `make reference` fails, revert the changes to `Reference/` that did
happen, and then make the PR opened a _Draft_ and add a warning to the
PR message to draw attention to the fact that it is likely incomplete
and the `Package.swift` will need updated.

While at it, mark two other workflows as only for the
apple/swift-protobuf repo so they don't run in forks.
2026-04-15 15:44:36 -07:00
Yuta Saito 2a43676e4d Fix missing python3 dependency in update_protobuf.yml workflow (#2025)
https://github.com/apple/swift-protobuf/pull/2021#discussion_r3074518914

Tested in forked repo:
https://github.com/kateinoigakukun/swift-protobuf/actions/runs/24356253992/job/71123847528
(it failed because of new files though)
2026-04-13 13:43:01 -04:00
Yuta Saito a1bb0e3374 Replace protobuf/abseil submodules with vendored sources (#2021)
Fixes apple/swift-protobuf#2000.

SwiftPM recursively checks out git submodules during package resolution.
The protobuf and abseil submodules are large C++ repositories, but every
consumer has to pay the cost of fetching them for every checkout because
SwiftPM cannot cache submodules as their bare repositories.

This PR replace protobuf/abseil submodules with vendored sources.

## Commits

1. Add protobuf vendor update automation
3. Remove protobuf and abseil submodule
4. Vendor protobuf and abseil

Reviewers can focus on the first commit; commits 2 and 3 are mechanical.

## Alternative Considered

git subtree was also considered but ruled out: it does not support
selective path filtering across multiple directories (we only need a
subset of files from each repo).
2026-04-13 15:51:22 +00:00
Thomas Van Lenten d99d976380 Drop the known breaks file now that descriptor is back in sync. (#2023) 2026-04-13 15:02:15 +00:00
Thomas Van Lenten 28e6c43c79 Update proto file from upstream. (#2022)
Using upstream 34cb33b197d56d504d5dedd4344628f72a6cdc5f.
2026-04-13 14:30:33 +00:00
Thomas Van Lenten 7827f8c9d7 Drop the API break file. (#2018)
Like last time, only needed to land descriptor updates; which we don't
control and only plugins rely on the information and the plugin api we
expose hides these types of details, but we need to update the proto
file to part newer files.
2026-04-06 15:26:42 +00:00
Thomas Van Lenten ec664f7d77 Update proto files from upstream. (#2017)
Using upstream 109fde41db66fdf24763a7a429d1e0dc80459f1d.
2026-04-06 14:51:22 +00:00
Thomas Van Lenten aa35667e6d Update proto files from upstream. (#2015)
Using 29476e1a91dc3dfbc10a8d4a5bce998896452258.
2026-03-31 08:24:30 -04:00
Thomas Van Lenten b6b7d8db23 Add 6.3 into the testing matrix. (#2012)
Move the linage test to "latest", don't think we are going to track this
for every release where it could be possible.
2026-03-26 14:35:13 +00:00
Thomas Van Lenten fab992f62d Update proto files from upstream and regenerate. (#2009)
Using upstream 68bd6bed7923ddade82a57a6fb8274024a3cd5d8
2026-03-23 14:28:21 +00:00
Thomas Van Lenten a008af1a10 Version bump for a release to fix cocoapods. (#2008) 1.36.1 2026-03-13 16:15:02 +00:00
Thomas Van Lenten 8fe85bbd74 CocoaPods fix for the addition of traits. (#2007)
Maps the default `traits` to preprocessor defines when building the
library.

Tested by swapping the

```swift
#endif
```

for:

```swift
  #warning("Defined.")
#else
  #error("Not defined.")
#endif
```

And inspecting the output of `pod lib lint` to confirm the `#warning` is
hit and not the `#error`. Fixes #2005
2026-03-13 15:40:14 +00:00
Thomas Van Lenten f21a997b87 Move all scripts into scripts/, retired DevTools/ (#2003)
This is probably were folks will look for things, so might as well have
everything in one place.
2026-03-11 18:58:53 +00:00
Thomas Van Lenten 0375d17e60 Shuffle around the AsyncMessageSequence tests and add some. (#2002)
Reorder some of the tests to easily only exclude the ones that need the
Foundation support.

Also bring over some tests that the other class has that weren't done
here.
2026-03-11 18:27:39 +00:00
Thomas Van Lenten 86970144a0 Version bump for a release (#2001) 1.36.0 2026-03-10 15:33:13 +00:00
Mads Odgaard 603b00bd51 Add Foundation linkage test and last missing pieces (#1997)
Adds linkage test to make sure we don't regress importing Foundation.

Also, the `.copy` resources in SwiftPM imports full Foundation, so we
guard that behind Darwin.

Also fixes the last remaining Foundation part, which was
`String.contains`.

## Result
`swift-protobuf` can now be built with `FoundationEssentials` only.
2026-03-10 08:35:52 -04:00
Thomas Van Lenten 2654646d2e Add some Makefile helpers for checking on the traits locally. (#1999) 2026-03-09 15:12:43 +00:00
Thomas Van Lenten 0892bd1a91 Update protos from upstream & regenerate. (#1998)
Using upstream efd47196d84e4e3adf8463d7260eaef38fd130aa.
2026-03-09 14:24:44 +00:00
Mads Odgaard aac2b602f6 Introduce default traits (#1995)
Follows up on the discussion in #1993 and introduces the traits:
* `BinaryDelimitedStreams`
* `FieldMaskSupport`
2026-03-06 10:26:37 +01:00
Mads Odgaard b16843c4f8 Move runtime to FoundationEssentials (#1993)
As per the recent [forums
post](https://forums.swift.org/t/the-adoption-of-import-foundationessentials-throughout-the-package-ecosystem/84112/16)
on the `import FoundationEssentials`, this PR implements the strategy
described.

The generator now generates the conditional essentials import.

The only remaining part after this is to do something about the
`BinaryDelimited` APIs which use `InputStream` and `OutputStream`

Fixes #1756

---------

Co-authored-by: Franz Busch <f.busch@apple.com>
Co-authored-by: Thomas Van Lenten <thomasvl@google.com>
2026-03-01 11:05:47 -05:00
Mads Odgaard 33947400bd DoubleParser: use C import instead of Foundation (#1992)
Broke out from #1968

Instead of importing `Foundation` in the `DoubleParser`, we just import
the relevant C library which contains the `strtod` function.
2026-02-27 15:09:57 -05:00
Franz Busch 747d8b0205 Add an EnumGeneration option to generate @nonexhaustive enums and oneofs (#1987)
# Motivation

Swift protobuf currently generates exhaustive (aka frozen) enums;
however, in proto3 enums and oneofs are open and it is binary and wire
compatible to add new cases to either.

# Modifications

This PR introduces a new generator option called `EnumGeneration` that
allows developers to add the newly introduced `@nonexhaustive` attribute
to enums. Because adding this attribute is a source breaking change the
default stays the same as it currently is. Additionally, this PR adds
multiple tests for the protoc plugin and SwiftPM plugin.

# Result

We can now generate `@nonexhaustive` enums and oneofs.
2026-02-25 15:22:28 +00:00
Thomas Van Lenten e453221b73 Correct header (#1991)
Was still talking about the other artifacts that got used for a while.
2026-02-23 16:26:01 +00:00
Thomas Van Lenten 5596511fce Version bump for a release. (#1990) 1.35.1 2026-02-23 15:53:04 +00:00
Wolfgang Lutz f1ae0664ff fix plugin's path escaping on Darwin (#1989)
A port of https://github.com/grpc/grpc-swift/pull/2273 to fix the same
issue here.
2026-02-23 15:23:21 +00:00
Thomas Van Lenten 571f2300d7 Update proto files from upstream (#1988)
Using e8f93acee8364cf05abc2311f6dbcb1a56a3eeeb

The change to `descriptor.proto` doesn't get captured in the Swift; but it seems
our testing files were stale, so updating them now.
2026-02-23 12:52:02 +00:00
Thomas Van Lenten eefb84299d Properly detect when already using the current protobuf tag. (#1986)
There were two problems to address -

- The shallow checkout github actions do by default didn't have any tags
in the submodule, and we weren't fetching them until doing the update.
So fetch the tags for the protobuf module upfront so the steps can
properly inspect them.
- Since protobuf does language specific tags, most of the time a
language specific tag will be what was collected for the current
checkout, which would still result in all the work being done to then
decide nothing was needed. So change things to collect _all_ tags for
the current comment, and filter them down to the general protobuf tag
instead. This also now errors if anything goes wrong instead of doing
lots of work to then not make a PR.

Fixes #1904
2026-02-21 17:31:56 +01:00
Cory Benfield bb661fadbe Remove two unnecessary memory copies on Any. (#1985)
Two parts of `Any` will construct a `Data` unnecessarily, triggering a
memory copy. One is used to serialize a JSON body (stored as an Array of
UInt8) into a Data, by way of an intermediate Array. This intermediate
Array is not necessary: we should go directly to the final Data.

The second is accessing an already serialized value, which already has a
Data in hand, and calls `Data(thatData)`. This initializer looks
innocuous, but `Data` does not actually have a special-case for this, so
this ends up hitting the initializer that takes a `Sequence`, so does a
bulk copy operation instead.

This patch changes both of these to remove extra memory copies when
using Any.
2026-02-20 09:41:40 -05:00
Thomas Van Lenten d81eb56adf Take two on updating the badges. (#1984)
This time use the github ux to get the markup.
2026-02-17 17:44:58 +00:00
Thomas Van Lenten 810cef8685 Have the badges only show main status. (#1983)
That way if the most recent build was a PR (and it fails), someone
looking at the project page won't see failing badges.
2026-02-17 12:10:56 -05:00
Thomas Van Lenten 9bbb079b69 Version bump for a release. (#1982) 1.35.0 2026-02-17 17:24:40 +01:00
Thomas Van Lenten 73e82b6f10 Update .proto files from upstream. (#1981)
Using upstream 1074b288126b92e7996bfe3379c5c74336e72401.
2026-02-17 15:07:43 +00:00
Thomas Van Lenten f47dc2a1b9 Support spaces and comments in TextFormat extensions and AnyNames. (#1978)
Finish out the rest of the spec updates that allow this.

Fixes #1970
2026-02-11 21:34:54 +00:00
Thomas Van Lenten b29d497a98 Allow the rest of the spec to start a AnyName. (#1977)
I missed this part in #1974

Progress on #1970
2026-02-11 20:21:37 +00:00
Thomas Van Lenten 307c15a1aa Update the TextFormat whitespace parsing to match spec. (#1976) 2026-02-11 19:53:32 +00:00