Open amsam0 opened 1 year ago
Ah, thanks for reporting.
We generate C types on the fly to support bridging arbitrary Result<T, E>
combinations.
We do this once per bridge module so that we can use the same Result<T, E>
multiple times per bridge module.
What's happening here is that since our Result<T, E>
support type codegen doesn't currently normalize across multiple bridge modules, the Result support type in your example is getting generated twice.
Right now swift-bridge-build
iterates over all passed in Rust files and generated code for the bridge modules one by one.
One solution would be to make swift-bridge-build
first parse all of the bridge modules, then combine them into some sort of combined data structure, and then generate code from that combined data structure.
Not sure how much of an architectural change that would be. Need to look into it. Seems like you have a hacky workaround in the meantime fortunately.
Here's an example. In
lib.rs
I have:In another module, I have:
In another module, I have:
This causes duplicate header definitions (
ResultVoidAndErrors$Tag
):which Xcode then complains about.
A workaround is to add this to your build script: