1

Goal

I'm building an iOS app using flutter for frontend, and C/C++ as backend. They must interoperate through FFI, which is a language binding scheme through C dynamic libraries. I intend to submit it to iOS App Store.

Problems

The Dart FFI sample on accessing C-struct works on macOS through dynamic liking and binding. Now dynamic linking is technically possible on iOS according to Xcode 9 - No option to create dylib project iOS, however, it's unclear to me how to ship the app to AppStore, because dynamic linking is not allowed according to Apple Guidelines Section 2.5.2.

2.5.2 Apps should be self-contained in their bundles, and may not read or write data outside the designated container area, nor may they download, install, or execute code which introduces or changes features or functionality of the app, including other apps. Educational apps designed to teach, develop, or allow students to test executable code may, in limited circumstances, download code provided that such code is not used for other purposes. Such apps must make the source code provided by the Application completely viewable and editable by the user.

Quite a few SO questions confirm this problem, such as:

Then official flutter documentation says

Dynamically linked libraries are automatically loaded by the dynamic linker when the app starts. Their constituent symbols can be resolved using DynamicLibrary.process. You can also get a handle to the library with DynamicLibrary.open to restrict the scope of symbol resolution, but it’s unclear how Apple’s review process handles this.

Questions

  • As of the date when I post this (2020), does this say that I could never ship an app using this architecture to App Store?
  • Is it possible that I static link my C/C++ code into a single binary of a flutter app? Take Unity as an example, their iOS plugin system recompiles the plugin into native app. If flutter has a similar mechanism, how?
kakyo
  • 10,460
  • 14
  • 76
  • 140

2 Answers2

1

The answers saying you can't use dynamic libraries on iOS date to before iOS 8, when support for user-provided dynamic libraries was added.

Nothing in 2.5.2 days you can't use dynamic libraires as long as they are shipped as part of your app. So:

As of the date when I post this (2020), does this say that I could never ship an app using this architecture to App Store?

No it doesn't, as long as "this architecture" refers to using a dynamic library that you link to at build time and bundle into your application.

smorgan
  • 20,228
  • 3
  • 47
  • 55
0

Adding inputs from Reddit's FlutterDev channel

@escamoteur

As I understand it you are not allowed to load any library from outside your installation folder. Especially not downloading something at a later point of time. Could you make this a Stackoverflow question and tag it with Flutter?

@airflow_matt

Since iOS 8 there can be shared libraries in the bundle, when properly codesigned I don't see why dlopen wouldn't work. Or you can link the library with main executable itself (just like flutter does) and dlopen self (DynamicLibrary.process()). I think it's worth a shot.

Community
  • 1
  • 1
kakyo
  • 10,460
  • 14
  • 76
  • 140