Upvote:8
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.
- Create flutter app as usual and run it once on iOS simulator.
- Open Xcode workspace and add new framework. For my purposes I will name it RunnerLib.
- Change deployment target of that framework to be the same as for Runner. Also disable bitcode.
- Change target membership of App.framework and Flutter.framework to RunnerLib.
- Create Launcher class with one static method:
+ (void)launchFrom:(UIViewController *)parent
, this what should create a FlutterViewController and present it. - Rewrite the Runner to use Launcher class. Replace FlutterAppDelegate with standard AppDelegate, make ViewController, etc. It should look like standard native iOS project, so you could create one and copy over AppDelegate, storyboard and ViewController.
- Call launchFrom method in your view controller, in viewDidAppear or as IBAction on a button.
- You should be able to build the Runner and see that flutter screen appears.
- Now, if you build the Runner app, you can open the crated Runner.app, and see that Frameworks directory contains 3 frameworks: App, Flutter and Runner.
- You will need to have two sets of frameworks: one set for simulator, compiled in debug mode, and another set for devices - archived. Getting debug frameworks is pretty easy, just compile from Xcode and inspect the product. Archived frameworks are harder, I recommend doing
xcodebuild archive
with disabled signing. - Your users will have to configure their project to use correct frameworks depending on device. Possibly this step can be automated by Carthage and fat binaries, but I'm not sure. The problem is with App.framework which looks completely different on device than on simulator.
Source code: https://github.com/szotp/runner_lib
Upvote:4
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.
Credit Goes to: stackoverflow.com
Related question with same questions but different answers
- HOW TO EXPORT FLUTTER PROJECT AS SDK (IOS DYNAMIC FRAMEWORK) IN IOS
- FIREBASE DYNAMIC LINKS FOR MULTIPLE IOS APPS IN PROJECT IN IOS
- FOLLOWING CURSOR IN DYNAMIC UITEXTVIEW WITH UITABLEVIEW NO LONGER WORKING IN IOS 11 IN IOS
- IONIC FRAMEWORK AND FIREBASE 3.X VERSION: THIS DOMAIN IS NOT AUTHORIZED FOR OAUTH OPERATIONS FOR YOUR FIREBASE PROJECT IN IOS
- HOW TO SHORTEN A FIREBASE DYNAMIC LINK USING MY OWN DOMAIN NAME IN IOS
- EVEN BASIC IONIC PROJECT WITH CORDOVA WKWEBVIEW ENGINE PLUGIN PRODUCES WHITE SCREEN IN IOS
- HOW TO USE SUPERPOWERED LIB IN SWIFT PROJECT IN IOS
- HOW TO SET DYNAMIC WIDTH & HEIGHT OF A VIEW IN AUTOLAYOUT IN IOS? IN IOS
- ENABLE ICLOUD ON A XCODE PROJECT VIA SCRIPT IN IOS
- PUSH VIEW: WHILE AN EXISTING TRANSITION OR PRESENTATION IS OCCURRING; THE NAVIGATION STACK WILL NOT BE UPDATED IN IOS
- USING GLKMATH FROM GLKIT IN SWIFT IN IOS
- PULL TO REFRESH JUMP IN IOS IN IOS
- WHICH CGIMAGEALPHAINFO SHOULD WE USE? IN IOS
- NSURLSESSION PRIORITY IN IOS
- UIPERCENTDRIVENINTERACTIVETRANSITION WITH CABASICANIMATION IN IOS
- JSON TEXT DID NOT START WITH ARRAY OR OBJECT AND OPTION TO ALLOW FRAGMENTS NOT SET IN IOS
- HOW TO WRAP AN ASYNCHRONOUS METHOD THAT TAKES A BLOCK AND TURN IT SYNCHRONOUS IN OBJECTIVE-C IN IOS
- HOW TO TEACH XCODE TO INCLUDE ALL HEADER FILES IN OUTPUT OF STATIC LIBRARY PROJECT? IN IOS
- NIB MUST CONTAIN EXACTLY ONE TOP LEVEL OBJECT WHICH MUST BE A UITABLEVIEWCELL INSTANCE IN IOS
- SCALETIMERANGE HAS NO EFFECT ON AUDIO TYPE AVMUTABLECOMPOSITIONTRACK IN IOS
- IPHONE IOS PUSH NOTIFICATIONS APNS ON PRODUCTION NOT SENDING IN IOS
- WHEN A UIIMAGEVIEW'S IMAGE IS SET FROM INTERFACE BUILDER, HOW IS THAT IMAGE LOADED? IN IOS
- TRANSFORM NOT WORKING IN AVMUTABLEVIDEOCOMPOSITION WHILE EXPORTING IN IOS
- SOLVING COREDATA ERROR: NULL _CD_RAWDATA BUT THE OBJECT IS NOT BEING TURNED INTO A FAULT IN IOS
- IOS: THE + NUMBER VALUES IN BACKTRACES (IN CRASH LOGS) IN IOS
- RECEIVE LOCAL NOTIFICATIONS AFTER DELETING AND REINSTALLING AN IPHONE APP IN IOS
- OBJECTIVE-C DESIGN PATTERN FOR MANAGING OBSERVERS IN IOS
- RENEWING PROVISIONING PROFILE AND CERTIFICATES IN IOS
- (NSCFTYPE SET) - UNRECOGNIZED SELECTOR IN IOS 6 IN IOS
- WILL APPLE REJECT NEW APPS IF THEY ARE NOT CONSIDERING THE NEW IPHONE 5 RESOLUTION? IN IOS
- ALAMOFIRE REQUEST ALWAYS FAILS WITH "THE REQUEST TIMED OUT" IF SOCKET.IO IS CONNECTED IN IOS
- SCENEKIT – DRAWING ON 3D OBJECT IN IOS
- CORE DATA: STATEMENT IS STILL ACTIVE IN IOS
- XCODE IOS FRAMEWORK ICON MEANINGS IN IOS
- HOW TO USE SWIFT LIBRARY IN NATIVESCRIPT? IN IOS
- WHITE LABEL ANDROID AND IOS APPS IN IOS
- GET WORD FROM TAP IN UITEXTVIEW IN IOS
- XCODE - EXCLUDE CERTAIN STRINGS FROM LOCALIZATION IN IOS
- REAL TIME PITCH CHANGE WHILE RECORDING AUDIO WITH AVAUDIORECORDER IN IOS
- APPLE IOS - "APP LOCK" CONFIGURATION PROFILE SETTING (AKA "KIOSK MODE") ONLY WORKS WITH APPS INSTALLED THROUGH APPLE CONFIGURATOR IN IOS
- USE OF BEGINRECEIVINGREMOTECONTROLEVENTS IN IOS
- IOS 13 - USING BGTASKSCHEDULER DOESN'T WORK ALL THE TIME IN IOS
- DO YOU NEED TO DELETE IMPORTED FILES FROM DOCUMENTS/INBOX? IN IOS
- REMOVE BACKGROUND FROM IMAGE & TAKE ONLY IMAGE PART FOR SAVE IN IOS IN IOS
- MEMORY LEAK DRAWINRECT ON IOS5.0.1 IN IOS
- ARE XAMARIN IOS APPS BLOATED UNREASONABLY? IN IOS
- SUBCLASSING UIAPPLICATION TO OVERRIDE SENDEVENT CAUSES CRASH IN IOS
- HOW CAN I AVOID NSINTERNALINCONSISTENCYEXCEPTION WHEN TAPPING ON UI ELEMENTS WITH XCTEST? IN IOS
- HTML EMAIL DOESN'T DISPLAY IN IPHONE MAIL UNTIL 'DOWNLOAD FULL MESSAGE' SELECTED IN IOS
- CHANGE UIALERTCONTROLLER MESSAGE OR TITLE DURING ITS PRESENTATION IN IOS
- DEBUGGING ON APPLE WATCH NEVER PRINTS TO CONSOLE IN IOS
- DIDMOVETOPARENTVIEWCONTROLLER CALLED TWICE IN IOS
- UIAUTOMATION NESTED ACCESSIBILTY ELEMENTS DISAPPEAR FROM HIERARCHY IN IOS
- ITUNES CONNECT IN APP PURCHASE FREE TRIAL DURATION GONE? IN IOS
- IDENTIFYING THE TYPE OF TOUCH GESTURES FROM UIEVENT OBJECT IN IOS
- AVAUDIOPLAYER STOPS PLAYING IMMEDIATELY WITH ARC IN IOS
- ASYNCHRONOUS CODE DOESN'T EXECUTE UNTIL APP FOREGROUNDED IN APPLICATION:DIDRECEIVEREMOTENOTIFICATION:FETCHCOMPLETIONHANDLER: IN IOS
- GET RID OF MAGNIFYING GLASS IN IOS WEB APP IN IOS