dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
82 stars 27 forks source link

[Question] How to add .framework to asset correctly #1094

Closed rainyl closed 1 month ago

rainyl commented 1 month ago

I am building the native C wrappers of OpenCV using conan and CMake, referring to native_assets_toolchain_c, I can compile it successfully and get opencv_dart.framework for ios, the compiled framework looks like:

opencv_dart.framework
|-- Info.plist
`-- opencv_dart

1 directory, 2 files

But I don't know how to correctly add it to assets to consume in Flutter, I added the opencv_dart(i.e., the dylib, you can find more details here: https://github.com/rainyl/opencv_dart/blob/d5eea8976cfd645b8dba5e8fe17dcfad95b8b1e9/hook/native_toolchain_conan.dart#L162C5-L204C37) to asset as normal NativeCodeAsset, it worked on a simulator, I am not a experienced IOS developer but it seems with out info.plist, It can't be correctly upload to APP Store, https://github.com/rainyl/opencv_dart/issues/11

So, would you mind explain more about how to add the framework to asset of buildOutput correctly? Thanks a lot!

dcharkes commented 1 month ago

@rainyl nice to meet you!

Flutter itself packages things in a framework with a plist. The build.dart outputs a dylib (per architecture), and the iOS/MacOS build bundle these dylibs (each for every target architecture) in a framework with the correct plist.

If you're interested in the implementation:

It is not supported to provide a framework from build.dart.

I believe the automatic packaging into framworks by the implementation in Flutter is sufficient to publish to the store. See discussions on:

If this doesn't work for your use case, please let us know.

rainyl commented 1 month ago

Thanks! Native Assets is really useful to distribute native codes, waiting for it's graduation and thanks for your efforts!