-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift library mode --module-name
not applied to --swift-sources
#2362
Comments
Or perhaps a submodule for each uniffi-exporting Rust package in the generated modulemap in the XCFramework works and be more semantically correct? |
I think you're just missing configuration options - https://mozilla.github.io/uniffi-rs/latest/swift/configuration.html eg, see how one of the crates in the megazord is configured. |
I missed this part:
You can specify those options in any .toml file you like - we just look in the crate by default, but you can specify another on the command line. |
I'm using the uniffi-rs/uniffi/src/cli/uniffi_bindgen.rs Lines 91 to 93 in 8185a28
Can they be equivalent given with the correct options? I can't recall exactly why, but I think there were a few reasons why I'm using the Swift-specific entrypoint:
I'm not really blocked at the moment regarding this as I'm processing the output to make a Swift 6 patch(es) too in a custom cargo subcommand to make a local Swift package with the inner FFI XCFramework. I may give the config file thing and the shared entrypoint when I get a chance. Just thought it might have been an overlooked detail. |
Not sure what "they" you are referring to? All the documented swift options obviously work with the swift cli.
Don't worry too much about the megazord, it's the only way to ship uniffi if you share anything between multiple crates and we have a number of tests for that in this repo. We do need better swift docs though.
Using either one is fine.
Not sure what you mean there, but welcome PRs for docs. |
Cool, thanks, will try to send some PRs for docs or other things once I get my build system figured out and finished. |
Shouldn't
--module-name
option be used for all "canImport
" boilerplate when making a library mode multi-package bundle, a megazord in Mozilla terms? In other words, the module name specified on the Rust package that is used to build the library should override all transitive dependencies configuration for a module name?I just noticed that is why my script that was trying to make a multi-package bundle that compiles was failing.
I see that Mozilla has their megazord module name in the FFI Swift Code:
Because it is specified at the dependency Rust package in the
uniffi.toml
file (???):But that seems like it would prevent making different "remixes", by using different bundling-Rust packages, for use in different apps?
Example
In my example I have 3 Rust packages:
my-corp-foo
with single functionmy_corp_foo_greetings
my-corp-bar
with single functionmy_corp_bar_greetings
where they have just one function like the following with different names to avoid global conflicts:
my-corp-bundle
which has dependencies on the two above, and has alib.rs
file like:I then build
my-corp-bundle
across all of the desired apple targets, uselipo
to combine the macOS and iOS-sim libraries, generate sources with:after moving the Swift files out of
tmp-headers
create an xcframework inside the future Swift package directory:And then init the Swift package that uses the xcframework as a binary dependency. Basically learned how things worked from this blog post to have something like
mozilla/rust-components-swift
.The generated
my_corp_foo.swift
file is trying to import modulemy_corp_fooFFI
which doesn't exist. Only moduleMyCorpBundleFFI
exists which I specified with the--module-name
command line option.But after patching the Swift files with the updated module name and the
nonisolated(unsafe)
vars, I got it to compile for Swift 6 and tested the greeting function in an App that used theMyCorpBundleRust
Swift package as a local dependency.Caveats
MozillaRustComponents.xcframework
has an innerMozillaRustComponents.framework
for each slice:while mine does not:
The text was updated successfully, but these errors were encountered: