Skip to content
CAI
Software that uses CAICheck a score

apple/swift-protobuf

60.7

Adequate · 14 September 2026

29.7k

lines of production code

Swift

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the Swift implementation of the Protocol Buffers library, providing both a runtime for serializing and deserializing data and a code generator to produce Swift types from .proto definitions. It supports modern Swift concurrency patterns through Sendable and nonisolated declarations, and handles binary, JSON, and TextFormat encodings with configurable options. The project includes comprehensive tooling for fuzz testing, performance benchmarking, and conformance validation against upstream protobuf specifications.

How it got here

2016 — Swift 6 migration and build system modernization

15 changes.

The project underwent a significant infrastructure overhaul, migrating from Xcode and autotools to Swift Package Manager and CMake while raising the minimum Swift version to 6.1 and later 6.2. This period also saw the removal of bundled upstream dependencies and legacy test fixtures, alongside the introduction of asynchronous message streaming and comprehensive performance benchmarking tools.

2017–2023 — Fuzz testing and plugin infrastructure

16 changes.

This period focused on establishing comprehensive fuzz testing infrastructure for binary, JSON, and text formats, including configurable decoding options and regression test cases. It also introduced a native Swift Package Manager plugin for code generation and restructured the plugin library to support Protobuf Editions and modern code generation APIs.

2024–2025 — Swift 6 concurrency and Protobuf Editions support

15 changes.

The code generator was updated to emit concurrency-safe code by marking types as nonisolated and Sendable, while replacing string-based name maps with compact bytecode representations. Concurrently, the project integrated support for the new Protobuf Editions system, updating well-known types, conformance tests, and test fixtures to align with the latest upstream specifications and Swift 6 standards.

2026 — dependency vendoring and protobuf v36 update

8 changes.

The project transitioned from Git submodules to vendored copies of Abseil and Protocol Buffers, managed by a new update script to simplify local builds. It also integrated Protocol Buffers v36.0 schema definitions and added scripts for copyright and version synchronization. New compile-time tests and features were introduced to verify linkage, handle nonisolated declarations, and support custom JSON names for enum values.

Features

Add C++ and Swift performance harness generators

New shell scripts in the Performance/generators directory now generate C++ and Swift test harnesses for benchmarking. These harnesses exercise binary, JSON, and text serialization, as well as message population and equality checks, using both homogeneous (single field type) and heterogeneous (mixed field types) protocol buffer definitions to provide more comprehensive performance metrics.

Performance/generators · high confidence

Add binary-delimited stream fuzz testing

A new fuzzing target has been added to exercise the binary-delimited parsing and serialization logic for streams. This tool reads delimited messages from an input stream, parses them, and immediately serializes them back to verify round-trip integrity. To prevent timeouts on large, garbage-heavy inputs, the fuzzer limits itself to processing a maximum of 50 messages per run.

FuzzTesting/Sources/FuzzBinaryDelimited · high confidence

Add configurable fuzzing options for binary, JSON, and TextFormat formats

Fuzz testing now supports decoding and encoding options for Binary, JSON, and TextFormat formats. This allows fuzzers to control specific behaviors such as message depth limits, handling of unknown fields, deterministic ordering, and field name preservation, enabling more comprehensive and targeted testing of protocol buffer serialization and deserialization.

FuzzTesting/Sources/FuzzCommon · high confidence

Add fuzz testing for async protobuf message streams

A new fuzz tester has been added to exercise the parsing of Protobuf-delimited messages from an asynchronous byte stream. This tool reads up to 50 messages per run to prevent timeouts during fuzzing and focuses specifically on stream framing and parsing logic, intentionally skipping re-encoding to keep execution time low.

FuzzTesting/Sources/FuzzAsyncMessageSequence · high confidence

Add performance visualization harness for comparing benchmark results

The performance suite now includes a new visualization component that renders benchmark results as box plots and summary tables. This tool allows users to compare runtime metrics (median times) and harness sizes across different language implementations, highlighting the fastest language in green and applying color-coded warnings for slower multipliers. The visualization supports numeric sorting for median calculations and displays specific benchmarks such as message creation, field population, encoding/decoding, and equality checks.

Performance/js · high confidence

Introduce C++ and Swift performance harnesses with visualization support

Adds a new performance testing infrastructure in the Performance directory, including C++ (Harness.cc, Harness.h, main.cc) and Swift (Harness.swift, main.swift) harnesses that measure serialization and parsing times. The harnesses output tabular timing data and statistical summaries to stdout, while also writing structured results to a log file for visualization. A shell script (perf\_runner.sh) orchestrates the generation of test messages, compilation, and execution of both Swift and C++ harnesses, allowing comparisons between different code revisions or against the C++ implementation. An HTML visualization page (harness-visualization.html) is included to display the collected performance data.

Performance · high confidence

Introduce Swift Package Manager plugin for SwiftProtobuf

A new Swift Package Manager plugin has been added to the SwiftProtobuf library, allowing users to generate Swift code from .proto files directly within their SPM projects. The plugin reads a \swift-protobuf-config.json\ configuration file to support custom protoc paths, visibility modifiers (internal, public, package), file naming strategies (FullPath, PathToUnderscores, DropPath), and enum generation options (including @nonexhaustive). It also supports implementation-only imports and access levels on import statements, providing a native build-time integration for protobuf code generation.

Plugins/SwiftProtobufPlugin · high confidence

New FuzzTesting subpackage with dictionaries and build scripts

A new FuzzTesting directory has been added to the project, providing the infrastructure for fuzz testing SwiftProtobuf. This includes a Package.swift manifest, a build script (do\_build.sh) that supports building in both debug and release configurations with address and fuzzer sanitizers, and a dictionary generation tool (make\_FuzzBinary\_dict). The package ships with specific input dictionaries (FuzzBinary.dict, FuzzJSON.dict, FuzzTextFormat.dict, etc.) to guide the fuzzer on valid field tags and JSON/text format keys, along with a README explaining how to run the tests and handle regression fail cases.

FuzzTesting · high confidence

New asynchronous delimited message decoding and Any message storage refactoring

The library introduces an asynchronous sequence API for decoding size-delimited protobuf streams, allowing developers to process multiple messages from a byte stream concurrently without blocking. Additionally, the internal storage for the Google\_Protobuf\_Any well-known type has been refactored into a dedicated class to support on-demand format transformations, accompanied by a new error type to better describe unpacking failures.

Sources/SwiftProtobuf · high confidence

The repository now includes three new scripts in the scripts/ directory to support development workflows. CopyrightFixup.sh automatically updates or inserts Apple copyright headers in Swift and C++ source files. LibraryVersions.py synchronizes version numbers between the SwiftProtobuf.podspec and Sources/SwiftProtobuf/Version.swift, supporting both validation and update operations. run-linkage-test.sh verifies that the LinkageTest binary does not incorrectly link against libFoundation.so on Linux, ensuring proper trait-based linkage behavior.

scripts · high confidence

New test helper initializers for Protobuf descriptors

The SwiftProtobufTestHelpers module now provides convenient package-level initializers for Google\_Protobuf\_FileDescriptorProto, Google\_Protobuf\_FileDescriptorSet, and Google\_Protobuf\_EnumValueDescriptorProto. These additions simplify the creation of descriptor instances within tests by allowing direct initialization with common properties like name, dependencies, and text format strings, rather than requiring manual property assignment after instantiation.

Sources/SwiftProtobufTestHelpers · high confidence

Support for custom JSON names on enum values

The Swift code generator now supports the new \pb.enumvalue.json\ option, allowing users to specify a custom string for serializing individual enum values to JSON. This is implemented by adding generated support for the \google/protobuf/json\_enumvalue\_options.proto\ definition, which exposes the \string\ field on enum value options via SwiftProtobuf extensions.

Reference/Sources/protoc-gen-swift · high confidence

Removals

Removal of legacy Xcode project files

The \SwiftProtobufRuntime\_iOS.xcodeproj\ and \SwiftProtobufRuntime\_macOS.xcodeproj\ directories have been deleted. This removes the legacy Xcode project configurations, including build schemes, workspace data, and info plists, for both iOS and macOS targets. Users relying on these specific Xcode project files for building the library will need to switch to the project's primary build system (likely Swift Package Manager, given the presence of \Package.swift\ references in the deleted project files).

_SwiftProtobufRuntime\_iOS.xcodeproj, SwiftProtobufRuntime\macOS.xcodeproj · high confidence

Removed bundled Google Protobuf source files

The local copy of the \google/protobuf\ source tree has been removed, including core definitions like \any.proto\ and \descriptor.proto\, as well as various test and unit-test proto files (e.g., \unittest.proto\, \map\_unittest.proto\). This change eliminates the bundled upstream Protocol Buffers definitions from the repository.

Protos/google · high confidence

Removed conformance.proto definition

The conformance testing protocol definition file (conformance.proto) has been removed from the Protos/conformance directory. This file previously defined the messages and enums used for the conformance test suite, including ConformanceRequest, ConformanceResponse, and TestAllTypes. Its removal indicates that the local copy of these protocol buffer definitions is no longer maintained or required in this location.

Protos/conformance · high confidence

Removed obsolete Swift protobuf unit test proto files

The \unittest\_swift\_naming.proto\ and \unittest\_swift\_performance.proto\ files in the Protos directory have been deleted. These files previously contained test messages used to verify Swift code generation for reserved words, naming conventions, and performance benchmarks. Their removal indicates that these specific test fixtures are no longer maintained or required in this location.

Protos · high confidence

Behavioural changes

Abseil C++ library sources are vendored into the project

The Abseil C++ library is no longer included as a Git submodule; its source code, build configurations (Bazel and CMake), and license files are now directly committed to the repository under Sources/protobuf/abseil. This change ensures the library is always available for local builds and simplifies dependency management by embedding the code directly.

Sources/protobuf/abseil, Sources/protobuf/abseil/absl/time/internal/cctz, Sources/protobuf/protobuf/java/core · high confidence

Fuzz testing now supports configurable decoding and encoding options

The FuzzJSON and FuzzTextFormat fuzzers have been updated to extract and apply specific decoding and encoding options from the input stream. This allows the fuzzer to exercise different parsing and serialization behaviors (such as varying JSON or TextFormat formatting rules) rather than using default settings, improving the coverage of edge cases in message handling.

FuzzTesting/Sources/FuzzJSON, FuzzTesting/Sources/FuzzTextFormat · high confidence

Fuzzing binary now supports configurable decoding and encoding options

The FuzzBinary tool has been updated to extract and apply specific fuzzing options during the test input processing. It now passes decoding options (such as partial decoding) and encoding options directly to the SwiftProtobuf message initialization and serialization methods, allowing the fuzzer to exercise a wider range of parsing and serialization behaviors rather than using default settings.

FuzzTesting/Sources/FuzzBinary · high confidence

Generated code now uses nonisolated types and bytecode-based name maps

The generated Swift Protocol Buffer code for ModuleA has been updated to mark enums and messages as \nonisolated\ and conform to \Sendable\, enabling safe usage in concurrent contexts. Additionally, the internal name maps for enums and messages now use a compact bytecode representation instead of string-based maps, which reduces memory overhead and improves initialization performance.

CompileTests/MultiModule/Sources/ModuleA · high confidence

Generated code now uses nonisolated types and inline bytecode name maps

The Swift protobuf generator now emits message types marked as \nonisolated\ (conforming to \Sendable\) and replaces the previous \\_protobuf\_nameMap\ dictionary with a compact, inline bytecode string. This change improves concurrency safety and reduces the memory footprint of generated code in multi-module projects.

CompileTests/MultiModule/Sources/ImportsAPublicly, CompileTests/MultiModule/Sources/ImportsImportsAPublicly · high confidence

Performance harness now respects SWIFT\_EXEC and OTHER\_SWIFT\_FLAGS environment variables

The Swift performance test runner in Performance/runners/swift.sh now respects the SWIFT\_EXEC and OTHER\_SWIFT\_FLAGS environment variables, allowing users to specify a custom Swift compiler path (including those with spaces) and pass additional compiler flags during benchmarking. This change also updates the runner to use xcrun on macOS while omitting it on Linux, ensuring the harness works correctly across different operating systems.

Performance/runners · high confidence

PluginExamples updated for Swift 6.1 with new configuration demos

The PluginExamples location has been refreshed to target Swift 6.1 and run in Swift 6 language mode, ensuring generated code compiles under strict concurrency checks. This update adds several new example targets to demonstrate specific plugin capabilities: AccessLevelOnImport (using the \useAccessLevelOnImports\ config), CustomProtoPath (using \protoPath\), PathToUnderscores (resolving filename collisions), UsesWKTs (importing well-known types), and Nonexhaustive (generating \@nonexhaustive\ enums and oneofs). Corresponding tests have been added to verify these configurations.

PluginExamples · high confidence

Protobuf C++ compiler now includes Well-Known Types by default

The \protoc\ binary bundled in this location has been updated to automatically include the path to Google's Well-Known Types (WKT) during compilation. A new \main.cc\ entry point intercepts command-line arguments to inject the WKT include directory, ensuring that standard protos like \any.proto\ are found without requiring users to manually configure include paths. This change is accompanied by a version bump to protobuf v36.1 and abseil 20250512.1, and the removal of several hand-written Swift well-known type implementations (such as \Google\_Protobuf\_Any\ and \Google\_Protobuf\_Duration\) that are no longer needed or are superseded by the updated code generator.

Sources/Protobuf · high confidence

Support for empty files with \`import public\` re-exports

The code generator now correctly handles Protocol Buffer source files that contain no messages, enums, or extensions but utilize \import public\ for re-exporting symbols from other modules. A new test case, \ReExportAOnly\, verifies that such empty files are generated without errors, ensuring that re-exported types (such as enums, structs, and extensions) are properly exposed via \@\_exported\ even when the file itself lacks standard protobuf definitions.

CompileTests/MultiModule/Sources/ReExportAOnly · high confidence

Swift Protobuf updates to version 1.0.1 with Swift 6.1 support and vendored protoc

The library has been updated to version 1.0.1, raising the minimum supported Swift version to 6.1 (requiring Xcode 16.3 or later). The project now bundles and builds its own copy of the \protoc\ compiler and \abseil-cpp\ from vendored sources, removing the external dependency on a system-installed protobuf installation for building the plugin. The package manifest introduces new traits (\BinaryDelimitedStreams\ and \FieldMaskUtilities\) to enable optional APIs, and the build system has migrated from autotools to CMake with a new \Makefile\ structure. Additionally, the Xcode project has been dropped in favor of Swift Package Manager, and the \Data\ type from Foundation is now used for binary data serialization.

(repo-wide) · high confidence

SwiftProtobufPluginLibrary module restructured with Edition support and new CodeGenerator API

The SwiftProtobufPluginLibrary has been reorganized and significantly updated to support Protobuf Editions. A new \CodeGenerator\ protocol and \CodeGeneratorParameter\ interface provide a modern, structured way to build protoc plugins, replacing older manual response handling. The library now includes a \FeatureResolver\ to handle edition-specific feature defaults and ranges, and \Descriptor\ types have been extended with Edition-aware properties and deprecation comments. Additionally, a CMake build configuration has been added for the library, and internal utilities like \CodePrinter\ and \NamingUtils\ have been refined to support these changes.

Sources/SwiftProtobufPluginLibrary · high confidence

Updated Google Protobuf well-known types and descriptors to latest upstream specifications

The Protos/Sources/SwiftProtobuf directory has been refreshed with the latest upstream .proto definitions, introducing support for Protocol Buffers Editions (including new Edition enum values and SYNTAX\_EDITIONS) and adding the Any message definition. Several well-known types (such as Timestamp, Duration, Struct, and Wrappers) have been updated with improved documentation, corrected JSON mapping descriptions, and deprecation notices for legacy usage patterns. Additionally, the Go package paths for these types have been migrated from the legacy github.com/golang/protobuf to google.golang.org/protobuf, and C\# namespaces have been standardized to Google.Protobuf.WellKnownTypes across the affected files.

Protos/Sources/SwiftProtobuf · high confidence

Updated Protocol Buffers include definitions to v36.0

The \Sources/protobuf/include\ directory has been updated with the latest Protocol Buffers v36.0 schema definitions. This change introduces new \.proto\ files for language-specific features (C++, Go, Java, C\#) and compiler plugin interfaces, alongside updated standard definitions for well-known types like \Any\, \Api\, \Duration\, and \FieldMask\. For users, this ensures the library supports the latest protobuf editions and language-specific code generation options.

Sources/protobuf/include · high confidence

Updated conformance test protocol buffers to support Protobuf Editions

The conformance test suite's protocol buffer definitions have been updated to include support for the new Protobuf Editions system. This change introduces new test message schemas for the 2023 edition (covering both proto2 and proto3 syntax) and the unstable edition, alongside the existing legacy proto2 and proto3 test messages. These additions allow the conformance tests to validate that implementations correctly handle edition-specific features, such as explicit field presence, new encoding options, and edition-specific message types.

Protos/Sources/Conformance · high confidence

Updated conformance test suite with new message types and test categories

The conformance test runner and its generated message definitions have been updated to support the latest upstream Protocol Buffers test schemas. This includes new generated message types for the 2023 Edition and the Unstable Edition, alongside updated definitions for Proto2 and Proto3. The runner now recognizes and handles the new \textFormatTest\ and \jsonIgnoreUnknownParsingTest\ categories, allowing it to validate TextFormat encoding options and JSON unknown field handling. Additionally, the known failure list has been refreshed to reflect current test outcomes, including specific JSON field name duplicate issues.

Sources/Conformance · high confidence

Updated generated SwiftProtobuf runtime code from upstream

The generated Swift source files for Google's well-known protobuf types (such as Any, Api, Duration, Empty, FieldMask, Struct, and Timestamp) have been regenerated to align with the latest upstream .proto definitions. This update refreshes the internal message structures and serialization logic for these standard types, ensuring compatibility with the current version of the SwiftProtobuf runtime and reflecting any changes in the upstream protocol buffer specifications.

Reference/Sources/SwiftProtobuf · high confidence

Updated upstream Protocol Buffers reference files

The vendored reference files in Reference/upstream/google have been regenerated to match the latest upstream Protocol Buffers definitions. This update includes new or modified generated Swift types for core well-known types (such as \Any\, \Api\, and \Compiler\ plugins) and C++-specific feature options, ensuring the library stays synchronized with the upstream protobuf schema.

Reference/upstream/google · high confidence

Vendored protobuf and abseil sources are now managed by a dedicated update script

The repository now uses a new Python script, \scripts/UpdateProtobufSubtrees.py\, to manage the vendored copies of the protobuf and abseil-cpp libraries. This script replaces the previous submodule-based approach by shallow-cloning specific releases and pruning unused files (such as language-specific compilers and test data) to keep the vendored source tree smaller and tailored to the Swift package's needs. Users or maintainers can now update the vendored versions by running this script with an optional \--protobuf-tag\ argument, and the script automatically handles updating the \VERSIONS.json\ metadata file.

python · high confidence

protoc-gen-swift: New bytecode-based name maps and CMake build support

The Swift code generator now uses a compact bytecode format to represent text and JSON name maps, replacing the previous string-based approach to improve generation performance. This change introduces a new BytecodeWriter component and updates the generator to emit bytecode literals for field and enum name lookups. Additionally, the plugin now supports a CMake-based build system via a new CMakeLists.txt file, and includes various internal refactors such as moving generators to use Descriptors directly and updating import handling for \import public\ and \@\_implementationOnly\ directives.

Sources/protoc-gen-swift · high confidence

Test coverage

Add SwiftProtobuf linkage verification test; Add regression test cases for TextFormat and JSON parsing edge cases; Added compile test for InternalImportsByDefault with public visibility; Added compile test for nonisolated code generation; Added compile tests for multi-module \import public\ support; Added compile tests for multi-module, internal imports, hidden names, and nonisolated declarations; Added comprehensive test fixtures for SwiftProtobuf plugin and core library tests; Added comprehensive unit tests for SwiftProtobuf encoding, decoding, and async streams; Added generated test fixtures for nonexhaustive enums and protocol buffer descriptors; Added test protos for @nonexhaustive enum generation and extension range ordering; Added tests for fuzzing option extraction logic; Added tests for protoc-gen-swift descriptor handling and bytecode interpreter; Added tests for the SwiftProtobufPluginLibrary descriptor and feature resolution logic; Added tests for the experimental hidden names feature; Regenerated conformance test proto files for Swift; Removed LinuxMain.swift test runner; Updated Protobuf test suite with regenerated sources and helpers; Updated test fixtures to Swift 6 concurrency and API version 2.

Dependencies

Swift 6.2 toolchain support and new compile-time tests

The project now requires Swift 6.2 (or later) toolchains, updating the main Package.swift and all sub-manifests (CompileTests, FuzzTesting, PluginExamples) to use swift-tools-version 6.1 or 6.2. New compile-time test targets have been added to verify specific language features and configurations: ExperimentalHiddenNames, InternalImportsByDefault, LinkageTest, MultiModule, and NonisolatedDeclarations. Additionally, the FuzzTesting package now includes targets for binary delimited streams and async message sequences, while PluginExamples demonstrate usage of the SwiftProtobufPlugin with various options like AccessLevelOnImport and CustomProtoPath.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 61.

Lenses

  • Code Health 83
  • Architecture 98
  • Maturity 60
  • Readiness 51
  • Security 65
  • Domain Modelling 100

Changes since last survey

  • 300 commits — 278 feature/other, 22 fixes

By area

  • (root) — 57 commits
  • Sources/SwiftProtobuf — 39 commits
  • .github/workflows — 38 commits
  • Sources/protoc-gen-swift — 21 commits
  • Protos/Sources — 17 commits
  • Reference/upstream — 15 commits
  • Protos/upstream — 13 commits
  • Sources/SwiftProtobufPluginLibrary — 12 commits
  • Sources/Conformance — 10 commits
  • Sources/protobuf — 10 commits
  • Tests/SwiftProtobufTests — 9 commits
  • Protos/Tests — 8 commits
  • (repo) — 6 commits
  • .github/scripts — 5 commits
  • Documentation/API.md — 5 commits
  • Documentation/RELEASING.md — 4 commits
  • CompileTests/InternalImportsByDefault — 3 commits
  • PluginExamples/Sources — 3 commits
  • Protos/SwiftProtobufTests — 3 commits
  • Tests/SwiftProtobufPluginLibraryTests — 3 commits

Notable commits

  • fix: Add two more formatting fixes to the blame ignore.
  • fix: Bulk fix #file vs #filePath warnings. (#1973)
  • fix: CocoaPods fix for the addition of traits. (#2007)
  • fix: Fix DocC symbol links and placeholders in documentation comments (#2093)
  • fix: Fix Foundation import's access level in generated code
  • fix: Fix make_latest from Boolean to String (#1838)
  • fix: Fix a few Makefile references to be self consistent. (#1892)
  • fix: Fix accidentally inverted if statement
  • fix: Fix copy/paste in comment that has the wrong thing. (#1815)
  • fix: Fix encode to deal with questionable json_name usage. (#1934)
  • fix: Fix missing python3 dependency in update_protobuf.yml workflow (#2025)
  • fix: Fix swift-tools-version in [e-mail redacted] (#1958)
  • fix: Fix the Parameter name on Enum.init?(rawUTF8:) (#2162)
  • fix: Fix the update protobuf and abseil workflow (#1924)
  • fix: Float the bugfix version. (#1851)
  • fix: Quick fixes for some of the documentation issues. (#1926)
  • fix: Revert "Pin docc to a version that works for older swift versions."
  • fix: Revert "Upload artifact bundle"
  • fix: Version bump for a release to fix cocoapods. (#2008)
  • fix: build: Fix CMake configuration and correct arm64 architecture detection (#1961)
  • …and 280 more

Architecture

  • 0 containers · 1 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

apple/swift-protobuf was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 14 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 87d0393435df31637c947d42f340b811049539c6 — the exact code this score is about.
  • Scored under rubric-2026.09.11 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-af56a6303ce2.