5 Commits

Author SHA1 Message Date
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
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
Mads Odgaard 082fc9052b Add option to set custom proto path (#1920)
Allows the developer to supply a custom directory that will be used as
the base of the protofiles.

```json
{
    "invocations": [
        {
            "protoFiles": [
                "file1.proto",
                "file2.proto",
            ],
            "visibility": "public",
            "protoPath": "proto_repo_submodule/protos"
        }
    ]
}

```

This is useful if you are storing protofiles inside a Git repo and
adding that as a submodule to other repos. Giving you a directory
structure like:

```
MySwiftApp/
  - Sources
    - MyAppTarget
      - proto_repo_submodule
        - protos
          - file1.proto
          - file2.proto
```

and any proto files will be importing other proto files relative to that
"protos" directory:

such as in **file1.proto**
```protobuf
import "file2.proto"
```

---------

Co-authored-by: Thomas Van Lenten <thomasvl@google.com>
Co-authored-by: Franz Busch <f.busch@apple.com>
2026-01-22 10:06:08 +00:00
Thomas Van Lenten ac8da77c93 Run swift-format -p -r -i . 2024-09-09 14:39:36 -04:00
Franz Busch 604e01ab4f Add tests for SPM plugin (#1387)
# Motivation
We have seen a few issues with the SPM plugin over time that we could have caught with tests.

# Modification
This PR adds a new tested `PluginExamples` folder that contains a standalone package that exercises the plugin in various configuration. This does not only help in testing the various configurations but also is a good resource for people that want to adopt the plugin.

# Result
We now have tests in place making sure our plugin works
2023-03-27 10:39:51 -04:00