flutterust icon indicating copy to clipboard operation
flutterust copied to clipboard

Add instructions for macos support

Open andrewdavidmackenzie opened this issue 3 years ago • 13 comments

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

andrewdavidmackenzie avatar Nov 08 '20 18:11 andrewdavidmackenzie

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

andrewdavidmackenzie avatar Nov 14 '20 19:11 andrewdavidmackenzie

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!

shekohex avatar Nov 15 '20 03:11 shekohex

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 avatar Nov 15 '20 08:11 andrewdavidmackenzie

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.

andrewdavidmackenzie avatar Nov 15 '20 09:11 andrewdavidmackenzie

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 😉

shekohex avatar Nov 15 '20 10:11 shekohex

Screenshot 2020-11-15 at 14 31 42

:-(

andrewdavidmackenzie avatar Nov 15 '20 13:11 andrewdavidmackenzie

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

andrewdavidmackenzie avatar Nov 15 '20 13:11 andrewdavidmackenzie

I alse meet the same problem

myway7 avatar Dec 08 '20 11:12 myway7

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.

myway7 avatar Dec 08 '20 11:12 myway7

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

shekohex avatar Dec 08 '20 11:12 shekohex

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

adamcypher avatar Aug 09 '21 20:08 adamcypher

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

suyulin avatar Aug 25 '21 08:08 suyulin

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

adamcypher avatar Sep 10 '21 17:09 adamcypher