shekohex / flutterust

Flutter + Rust = :heart:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add instructions for macos support

andrewdavidmackenzie opened this issue · comments

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

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

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:

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

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!

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

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.

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 😉

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

I alse meet the same problem

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.

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

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

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

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