Desdaemon / flutter_rust_bridge_template

Template for Flutter + Rust integration with flutter_rust_bridge.
https://desdaemon.github.io/flutter_rust_bridge_template/
Apache License 2.0
120 stars 63 forks source link

Code generation causes compilation failure for web #38

Closed elliotsayes closed 1 year ago

elliotsayes commented 1 year ago

On bare template, after running (as per docs):

flutter_rust_bridge_codegen --rust-input native/src/api.rs --dart-output ./lib/bridge_generated.dart --dart-decl-output ./lib/bridge_definitions.dart

I get compilation failure for web. Happens even when using the same version of flutter_rust_bridge_codegen as the template. Might be related to the following lines disappearing from bridge_generated.rs ?:

/// cbindgen:ignore
#[cfg(target_family = "wasm")]
#[path = "bridge_generated.web.rs"]
mod web;
#[cfg(target_family = "wasm")]
pub use web::*;
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.1, on macOS 13.0 22A380 darwin-arm64, locale
    en-NZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.74.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!
elliotsayes commented 1 year ago

Full diff: https://github.com/elliotsayes/flutter_rust_bridge_cipher_test/compare/main...codegen-failure-web

Desdaemon commented 1 year ago

Your invocation is missing the --wasm flag, but assuming you came here from the docs it might be worth updating it as well.

elliotsayes commented 1 year ago

True! I'll make a PR to update the docs with this