uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Fix "Creating the bindgen binary" tutorial to reference the `cli` feature.

Open SalvatoreT opened this issue 2 years ago • 5 comments

I followed the tutorial for generating the bindgen binary, and it works for generating bindings! However, now when I call cargo build on my (single crate) project, I get an error because of the missing uniffi/cli feature logic.

❯ cargo build
   Compiling example v0.1.0 (/Users/sal/Development/example)
error[E0425]: cannot find function `uniffi_bindgen` in crate `uniffi`
 --> uniffi-bindgen.rs:2:13
  |
2 |     uniffi::uniffi_bindgen()
  |             ^^^^^^^^^^^^^^ not found in `uniffi`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `example` due to previous error

Is there a way to set this up without breaking cargo build? Should I be doing this in a different crate, or is there a different macro I should use?

I'm admittedly newer to Rust and cargo, so the problem might be me. 😅

┆Issue is synchronized with this Jira Task ┆Issue Number: UNIFFI-241

SalvatoreT avatar Mar 04 '23 06:03 SalvatoreT

You will need to enable the cli feature on the dependency, as you correctly call out. The Multi-crate workspaces paragraph below calls that out, but you are right that this will probably required in any case to not break a simple cargo build.

I see to get the docs changed.

badboy avatar Mar 13 '23 14:03 badboy

Thank you!

SalvatoreT avatar Mar 13 '23 15:03 SalvatoreT

Workaround: cargo build --lib will continue to work.

heinrich5991 avatar May 17 '23 07:05 heinrich5991

I have included the feature flag cli in dependencies and it works.

[dependencies]
uniffi = { version = "0.24.3", features = ["cli"] }

[build-dependencies]
uniffi = { version = "0.24.3", features = ["build"]}

abrark-co2 avatar Oct 30 '23 15:10 abrark-co2

This will create an unnecessary dependency of the library on the CLI dependencies.

heinrich5991 avatar Oct 30 '23 21:10 heinrich5991