Swift generation ignores proto packages, leading to name collisions.
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
When generating Swift code, the proto package is ignored, and all files are output in the same directory. This can easily lead to name collisions where there are two types with the same name, but in different packages.
The protobuf spec says:
// By default Swift generators will take the proto package and CamelCase it
// replacing '.' with underscore and use that to prefix the types/symbols
// defined. When this options is provided, they will use this value instead
// to prefix the types/symbols defined.
optional string swift_prefix = 39;
The Swift generator is not creating this CamelCase with underscores type prefix. I didn't check, but it seems likely that the Swift generator is also ignoring the swift_prefix file option.
I understand that Wire is taking a different approach with Swift but this should be opt-in. The default behaviour should be to create the type prefixes based on the proto package.
As an aside, there is absolutely zero documentation about the --experimental-module-manifest option other than the above linked blog post, which took me a long time to find.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Swift generation behavior against the protobuf descriptor.proto documentation for the proto package and swift_prefix option. Reproduce generation with two types sharing a name across packages, then verify that generated symbols receive the expected package-based or configured prefixes and that module-manifest behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100