Swift experimental-module-manifest cannot reference enums from another module
Open
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
We've found that swift modules do not work when referencing enums.
Here's a repo that reproduces the issue.
TL;DR
proto/foo/v1/foo.proto
syntax = "proto3";
package foo.v1;
import "bar/v1/bar.proto";
// Foo represents a basic entity with a single Bar field
message Foo {
bar.v1.Bar bar = 1;
}
proto/bar/v1/bar.proto
syntax = "proto3";
package bar.v1;
// an example enum
enum Bar {
BAR_UNSPECIFIED = 0;
BAR_A = 1;
BAR_B = 2;
}
wire.yaml
Foo:
roots:
- foo.v1.*
dependencies:
- Bar
Bar:
roots:
- bar.v1.*
❯ rm -rf swift/modules && java -jar wire-compiler-5.3.3.jar \
--proto_path=proto/ \
--swift_out=swift/modules \
--experimental-module-manifest=wire.yaml
Writing .Bar declared in bar/v1/bar.proto to swift/modules/Bar (target=Swift)
Exception in thread "main" java.util.NoSuchElementException: Missing a zero value for Bar
at com.squareup.wire.swift.SwiftGenerator.validateProto3DefaultsExist(SwiftGenerator.kt:312)
at com.squareup.wire.swift.SwiftGenerator.generateMessage(SwiftGenerator.kt:335)
at com.squareup.wire.swift.SwiftGenerator.generateType(SwiftGenerator.kt:269)
at com.squareup.wire.swift.SwiftGenerator.generateTypeTo(SwiftGenerator.kt:256)
at com.squareup.wire.swift.SwiftSchemaHandler.handle(SwiftSchemaHandler.kt:47)
at com.squareup.wire.schema.SchemaHandler.handle(SchemaHandler.kt:152)
at com.squareup.wire.schema.SchemaHandler.handle(SchemaHandler.kt:43)
at com.squareup.wire.swift.SwiftSchemaHandler.handle(SwiftSchemaHandler.kt:34)
at com.squareup.wire.schema.WireRun.execute$wire_schema(WireRun.kt:321)
at com.squareup.wire.schema.WireRun.execute(WireRun.kt:240)
at com.squareup.wire.WireCompiler.compile(WireCompiler.kt:228)
at com.squareup.wire.WireCompiler$Companion.main(WireCompiler.kt:302)
at com.squareup.wire.WireCompiler.main(WireCompiler.kt)
The same proto files generate without experimental-module-manifest.
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
Run the linked enum reproducer with the shown proto files, wire.yaml, and --experimental-module-manifest. Start at SwiftGenerator.kt:312 and follow the generateMessage/generateType path shown in the trace. Done means the same modules generate successfully when Foo references the enum Bar from another module, as they do without the manifest.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100