You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for this tool! I was building something similar and found this.
I'm moving from cbindgen and simple xcframeworks to using uniffi and cargo-swift to generate the swift package.
My Rust crate has some differences between the API's exposed for iOS and macOS.
This works fine with xcframeworks, since each target platform has its own set of headers and library within the xcframework.
The generated Greeter swift package for the hello-world example only a single header file, but does contain an xcframework.
This code in package.rs seems to generate bindings for the first provided architecture only:
let archs = targets
.first().ok_or("Could not generate UniFFI bindings: No target platform selected!")?
.architectures();let arch = archs.first();let lib_path:Utf8PathBuf = format!("{target}/{arch}/{mode}/{lib_file}").into();
Question: Is this due to a limitation of swift packages, or can the generated swift package have multiple swift files, with conditional expressions to indicate which target platform each file is for?
Update: I found this document which indicates that conditional target dependencies are supported by swift packages.
In light of the above, could we please change cargo-swift to emit swift files with conditional dependencies per target os?
The text was updated successfully, but these errors were encountered:
coolbluewater
changed the title
Handling varying APIs based on platform
Handling varying APIs by OS
Feb 25, 2024
Hi, thanks for this tool! I was building something similar and found this.
I'm moving from cbindgen and simple xcframeworks to using uniffi and cargo-swift to generate the swift package.
My Rust crate has some differences between the API's exposed for iOS and macOS.
This works fine with xcframeworks, since each target platform has its own set of headers and library within the xcframework.
The generated
Greeter
swift package for thehello-world
example only a single header file, but does contain an xcframework.This code in
package.rs
seems to generate bindings for the first provided architecture only:Question: Is this due to a limitation of swift packages, or can the generated swift package have multiple swift files, with conditional expressions to indicate which target platform each file is for?
Update: I found this document which indicates that conditional target dependencies are supported by swift packages.
In light of the above, could we please change cargo-swift to emit swift files with conditional dependencies per target os?
The text was updated successfully, but these errors were encountered: