Skip to content
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

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

Open
SalvatoreT opened this issue Mar 4, 2023 · 5 comments
Open
Assignees
Labels

Comments

@SalvatoreT
Copy link
Contributor

SalvatoreT commented Mar 4, 2023

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

@badboy
Copy link
Member

badboy commented Mar 13, 2023

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 badboy self-assigned this Mar 13, 2023
@SalvatoreT
Copy link
Contributor Author

Thank you!

@heinrich5991
Copy link
Contributor

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

@abrark-co2
Copy link

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"]}

@mhammond mhammond changed the title "Creating the bindgen binary" tutorial instructions breaks cargo build Fix "Creating the bindgen binary" tutorial to reference the cli feature. Oct 30, 2023
@heinrich5991
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants