irondash / cargokit

Integrate cargo build with flutter plugins and applications.
Other
58 stars 18 forks source link

About the characteristics of platforms #4

Closed bookshiyi closed 1 year ago

bookshiyi commented 1 year ago

Hi, @knopp, Thank you for providing this great project. I try to understand the specific implementation of cargokit on different platforms:

Target Toolchains Type Suffix
Android Gradle  cdylib .so
iOS Cocoapods staticlib .a
macOS Cocoapods staticlib .a
Windows cmake cdylib .dll
Linux cmake cdylib .so

Is this a reasonable summary?


btw: The name of file build_android.rs and function build_android() not was build_gradle, is there any special consideration for doing this? How do you think that change name build_android to build_gradle without any logic changes?(like #5 )

knopp commented 1 year ago

This is correct. Ideally I'd want to use dylib on all platforms, but unfortunately it is not possible right now, at least on iOS.

There are two ways for cargokit (that I can think of) to do dynamic libraries on iOS, unfortunately both of them are flawed:

  1. Run the pod build script after framework build, replace the pod framework dylib with rust built code. The problem with this is that Xcode will not notice this and after rebuild it will not copy the updated framework to destination app bundle.

  2. Put rust dylib inside cocoa pod framework, update dylib install name and link it with framework. This would work in theory, unfortunately on iOS frameworks are not allowed to contain secondary dylibs (that is dylib other than ExecutableName declared in Info.plist). So this would get rejected during AppStore submission.

While 2. would technically work on macOS, I'm not sure it is it's worth the inconsistency if we can't do it on iOS anyway.

bookshiyi commented 1 year ago

@knopp Thanks for your reply.

How do you think that add detailed documents such as startup, roadmap, architecture to this project?

knopp commented 1 year ago

There is a tutorial available here:

https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/

I should probably add it to the README. Other than that, any documentation PRs are welcome :)