Search code examples
c++iosreact-nativeflutterphonegap

Can I mix C++ code (or library written in C++) with hybrid mobile app code?


I'm wondering is it possible to use C++ code mixed with hybrid mobile applications like React Native, Flutter, Phone Gap etc? I know it's possible to mix C++ code with Objective-C++ also for Android it's possible to use Java and C++ together. Except mentioned things Dropbox Djinni can allow shared C++ code usage for iOS and Android. But I don't know can we mix C++ with hybrid stuff.


Solution

  • You can use C++ libraries from Flutter.

    You need to make the functionality available on the native platform (Java/Kotlin and/or Objective-C/Swift) and then make it available to Flutter using by building a plugin https://flutter.io/docs/development/packages-and-plugins/developing-packages#developing-plugin-packages

    There is work in progress to make it easy to call out to C++ directly from Dart using FFI, https://github.com/flutter/flutter/issues/7053, https://github.com/dart-lang/sdk/issues/34452 but it's not yet available.