We have built an awesome Flutter project, which has great functionality we want to export as a framework, just like native libraries do, so that the source code is hidden (convert to dynamic framework).
We have followed the instructions: https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps
which allows us to include Flutter project in a Host iOS app, initializing FlutterEngine
and use of FlutterViewController
.
The question is, how do we create a dynamic framework, let's say SomeProductSDK.framework, which will expose a public methods to create our SomeProductSDK related modal screens?
// In any app
import SomeProductSDK
let controller = TransactionViewController() // SomeProductSDK.framework with partial implementation with flutter
self.present(controller, animated: true)
I've partially achieved what you want. All of this is very experimental and overall a bad idea for production ready SDK. But... it's possible.
+ (void)launchFrom:(UIViewController *)parent
, this what should create a FlutterViewController and present it.xcodebuild archive
with disabled signing.Source code: https://github.com/szotp/runner_lib
In order to export the framework as a native library you'll have to ensure that the person who'll use your framework (user) has Flutter SDK installed onto his computer as your framework's code will surely be dependent on Flutter SDK by default. So what your trying to do is equivalent of having your own package on pub.dev.
If you find some way to make the framework you want to export - independent of Flutter's framework, only then exporting it as an framework would make sense. (Doing that should be possible beyond doubt, but see the amount of work and time you'll put in just to get your framework there. You could have built your own Flutter framework in those same efforts and time)
Since you have already made that awesome Flutter Project, consider uploading it as an package on https://pub.dev/ if you wish to.
Suggestion: You can ask the users who want to try your package to install Flutter. This way your hardwork won't go in vains.
Conclusion: It is not practically feasible to achieve what your trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With