Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Flutter into CocoaTouch SDK?

Tags:

ios

sdk

flutter

I was able to follow the instructions on https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps to add Flutter as a dependency to a simple single view app and display a FlutterViewController, but did not have success trying the same process for a cocoa touch framework that depends on Flutter.

Is this currently possible? My hope was to be able to build a standalone iOS SDK that is powered by Flutter that other iOS apps could depend on with no direct dependency on Flutter.

Specifically when I tried the SDK approach, Flutter imports failed to resolve with errors relating to not being able to find the Flutter module imports:

[Xcode build error][1]][1]
error: no such module 'FlutterPluginRegistrant'
import FlutterPluginRegistrant
error: no such module 'Flutter'
import Flutter

Update: These are the error logs I was seeing initially, but was able to get around them by vendoring the FlutterPluginRegistrant.framework and Flutter.framework with Cocoapods. With that my main app compiles fine when linked to my FlutterSDK framework that includes the flutter dependencies. The issue I'm running into now is with setting up FlutterViewController and it's FlutterEngine / FlutterDartProject to point to the correct paths within the framework for the flutterAssets / dartMain / packages urls. I'm not sure how to pull these in from the framework.

like image 318
donalbain Avatar asked Nov 17 '18 05:11

donalbain


People also ask

Can you integrate third-party native SDKs into Flutter apps?

To get started, you can: One of the dilemmas that developers (or CTOs) might have is if it would be possible to integrate existing third-party Native SDKs (and functionality) into Flutter apps. Good news — It is very much possible.

How do I use flutter on iOS and Android?

Create a wrapper around the Flutter native SDKs and create a separate UI (built-in dart) that will be used across both the iOS and Android versions — assuming that the Flutter native SDKs will expose the necessary methods.

How to integrate TokBox chat app with flutter?

Therefore to use the functionality, there are two ways to go about this: You can directly call native Android and iOS SDKs of Tokbox chat app from your Flutter application — wherein the UI will be driven by Tokbox SDKs.

What is flutter and how it works?

Flutter uses a flexible system that allows you to write a platform-specific code either in Java or in Kotlin for Android & in Swift or Objective-C for iOS. Step 2: The host listens to the Platform channels and receives the message.


1 Answers

If you want to build a Framework that is essentially _just_ a Flutter module, where other iOS apps can use it without having to install/depend on Flutter SDK themselves, then yes, this can be done via one of the flutter/add-to-app options for iOS:

  • Option B - Embed frameworks in Xcode
  • also refer to the github/flutter/ios_using_prebuilt_module sample

On the other hand, if you are talking about integrating Flutter into an existing Framework, Flutter + Cocoa Touch, then no, this is currently not supported, but is being explored:

  • https://github.com/flutter/flutter/issues/39027
  • note that this would be termed “add-to-library” as opposed to "add-to-app"
  • also mentioned, flutter/add-to-app:

    Packing a Flutter library into another sharable library or packing multiple Flutter libraries into an application isn’t supported.

like image 123
TWL Avatar answered Oct 16 '22 07:10

TWL