irondash / cargokit

Integrate cargo build with flutter plugins and applications.
Other
51 stars 16 forks source link

iOS podspec affects Android build #62

Open OueslatiGhaith opened 5 months ago

OueslatiGhaith commented 5 months ago

I've encountered a weird behavior while trying to use flutter_rust_bridge, specifically while building using flutter run, after running cargo build --target aarch64-linux-android I got the following error.

error: failed to run custom build command for `dart-sys-fork v4.1.1`

Caused by:
  process didn't exit successfully: `/home/ghaif/Desktop/my_app/build/rust_builder/build/debug/build/dart-sys-fork-3927c6744642428a/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-linux-android")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_aarch64-linux-android
  CC_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CC_aarch64_linux_android
  CC_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_aarch64-linux-android
  CFLAGS_aarch64-linux-android = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_linux_android
  CFLAGS_aarch64_linux_android = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "aarch64-linux-android-clang" "-O0" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-I" "/home/ghaif/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dart-sys-fork-4.1.1/dart-sdk/include" "-Wall" "-Wextra" "-o" "/home/ghaif/Desktop/my_app/build/rust_builder/build/aarch64-linux-android/debug/build/dart-sys-fork-713bd8a87951eb3d/out/034bb5def7e8433c-dart_api_dl.o" "-c" "/home/ghaif/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dart-sys-fork-4.1.1/dart-sdk/include/dart_api_dl.c"

  --- stderr

  error occurred: Failed to find tool. Is `aarch64-linux-android-clang` installed?

By following this comment, I was led to the fix of adding the -framework SystemConfiguration flag to the iOS podspec, which weirdly enough fixed the issue with android builds.

It is worth mentioning that flutter run succeeds after applying this fix, but cargo build still gives the same error.

You can find more details here: fzyzcjy/flutter_rust_bridge#1722

knopp commented 5 months ago

There's no reason why that should have any impact on it. The error clearly says that the the NDK compiler couldn't have been found. It is possible that it passed the second time you have invoked the build (unrelated to the podspec file modification). Can you consistently reproduce the build failure when you remove -framework SystemConfiguration from the podspec?

OueslatiGhaith commented 5 months ago

yes, both flutter run and cargo build fail when I remove it, when I add it back, flutter run works, but cargo build doesn't

Edit: I have android studio and the NDK installed

patmuk commented 4 months ago

I second this, exactly the same symptom and solution, but on MacOS (14.2.1.) instead of Linux. And my own project, using FRB, which uses CargoKit.

Any idea what this could be?