Rust Interop: Generating bindings for Swift modules

As part of my Swift interop for Rust project (and eventually the reverse Rust interop for Swift), I'm going to want to generate bindings to Swift modules. Ideally I would have type layouts (fields, variants, etc.) to generate structs and symbol information (mangled names and signatures) to generate functions.

I'd like to start my proof of concept with generating bindings for the Standard Library and Apple frameworks.

Are .swiftmodule files sufficient or at least helpful for that? If so where can I find documentation on their format? If not, how else could I get that information?

3 Likes

I've determined that the .swiftinterface files present in Xcode's SDKs are basically what I want, but I'd need the Swift compiler to go through and provide the layout and signatures with mangled names.

Are there any libraries that do this? Any compiler tools?

I can potentially use swiftc to parse the .swiftinterface and emit additional metadata I might be able to combine with the .tbd file? How can I invoke swiftc in "interface" mode?