shekohex / flutterust

Flutter + Rust = :heart:
Apache License 2.0
699 stars 56 forks source link

Add instructions for macos support #11

Open andrewdavidmackenzie opened 3 years ago

andrewdavidmackenzie commented 3 years ago

now that flutter supports Mac OS, it would be great to include instructions for macos in the readme.

andrewdavidmackenzie commented 3 years ago

I've tried using all the usual instructionsn to enable mac os that work on other apps, it builds and tries to start but you get the "platform not supported" window shown.

Screenshot 2020-11-14 at 20 15 50
shekohex commented 3 years ago

did you add the macOS for the codegen at build.rs? Here for example you could configure the dart-bindgen so you could add more platforms: https://github.com/shekohex/flutterust/blob/41ae6da2461180f4e3123ed79d7f714825dcdb8a/native/adder-ffi/build.rs#L13-L17

on macOS you should just build using cargo build and it should generate .dylib file in the traget/debug. but I guess better add the config in the Makefile.toml.

Feel free to open a PR!

andrewdavidmackenzie commented 3 years ago

I don't think I know enough about how all this works to do either of the options you mention, but I will keep looking into it...

something like:

    let config = DynamicLibraryConfig {
        ios: DynamicLibraryCreationMode::Executable.into(),
        android: DynamicLibraryCreationMode::open("libadder_ffi.so").into(),
        macos: DynamicLibraryCreationMode::open("libadder_ffi.dylib").into(),
        ..Default::default()
    };

and modifying native/adder_ffi/Cargo.toml (manually to get it working first time) to:

[lib]
name = "adder_ffi"
crate-type = ["dylib"]

Maybe? (not working so far)

I also tried using the existing staticlib produced, with a reference to libadder_ffi.a in config, but no dice either.

Also tried:

[lib]
name = "adder_ffi"
crate-type = ["cdylib"]
andrewdavidmackenzie commented 3 years ago

I tried making the same Cargo.toml and build.rs modifications for scrap_ffi, then the error message change to:

Screenshot 2020-11-15 at 10 06 01

even though the .dylib file is in target/debug..

So, enough trying in the dark for now - I may come back to this later.

shekohex commented 3 years ago

You are close now, just instead of using libscrap_ffi.dylib use the full path relative to the dart executable i.e ../trarget/debug/libsceap_ffi.dylib.

Unfortunately I don't own mac device right now (getting one soon), but once my hands on one I will try to add that.

Unless you figured it out before me 😉

andrewdavidmackenzie commented 3 years ago
Screenshot 2020-11-15 at 14 31 42

:-(

andrewdavidmackenzie commented 3 years ago

Maybe if you can get one of the "desktops" supported by Flutter working, then I can copy and modify? https://flutter.dev/desktop

myway7 commented 3 years ago

I alse meet the same problem

myway7 commented 3 years ago

Compiling adder-ffi v0.1.0 (/Users/admin/flutterust/native/adder-ffi) error: failed to run custom build command for adder-ffi v0.1.0 (/Users/admin/flutterust/native/adder-ffi)

Caused by: process didn't exit successfully: /Users/admin/flutterust/target/debug/build/adder-ffi-b63e74a431e464b0/build-script-build (signal: 6, SIGABRT: process abort signal) --- stderr dyld: Library not loaded: @rpath/libclang.dylib Referenced from: /Users/admin/flutterust/target/debug/build/adder-ffi-b63e74a431e464b0/build-script-build Reason: image not found [cargo-make][1] ERROR - Error while executing command, exit code: 101 [cargo-make][1] WARN - Build Failed. [cargo-make] ERROR - Error while executing command, exit code: 1 [cargo-make] WARN - Build Failed.

shekohex commented 3 years ago

Hey @fbenpao, you need LLVM. see https://github.com/shekohex/flutterust#macos install it: brew install llvm

adamcypher commented 3 years ago

I get dyld: Library not loaded: @rpath/libclang.dylib and I have LLVM installed.

suyulin commented 3 years ago

m1 chip mac mini: dyld: Library not loaded: @rpath/libclang.dylib I have LLVM installed.

adamcypher commented 3 years ago

dart_bindgen and/or it's usage in build.rs is the culprit for the dyld: Library not loaded: @rpath/libclang.dylib error.