dart/flutter:如何将使用 flutter 前端与 C/C++ 后端的 iOS 应用程序发布到 App Store?
dart/flutter: How to ship iOS apps using flutter frontend vs. C/C++ backend to App Store?
目标
我正在构建一个 iOS 应用程序,前端使用 flutter,后端使用 C/C++。它们必须通过 FFI 进行互操作,FFI 是一种通过 C 动态库的语言绑定方案。我打算将其提交到 iOS App Store。
问题
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 , however, it's unclear to me how to ship the app to AppStore, because dynamic linking is not allowed according to Apple Guidelines 第 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.
不少SO问题证实了这个问题,例如:
- can I use dynamic library(shared object) in my iphone app?
- Will Appstore reviewers allow us to use dynamic library in iOS8?
然后official flutter documentation说
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.
问题
- 截至我 post 这个 (2020) 的日期,这是否表示我永远无法将使用此架构的应用程序发布到 App Store?
- 是否可以将 link 我的 C/C++ 代码静态化为 flutter 应用程序的单个二进制文件?以Unity为例,their iOS plugin system recompiles the plugin into native app。如果flutter有类似的机制,怎么样?
关于 iOS 不能使用动态库的回答可以追溯到 iOS 8 之前,当时添加了对用户提供的动态库的支持。
在 2.5.2 天内没有任何内容您不能使用动态库,只要它们作为您的应用程序的一部分提供。所以:
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?
不,它不会,只要 "this architecture" 指的是使用您 link 在构建时使用的动态库并将其捆绑到您的应用程序中。
从 Reddit 的 FlutterDev 频道添加输入
@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 Whosebug 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.
目标
我正在构建一个 iOS 应用程序,前端使用 flutter,后端使用 C/C++。它们必须通过 FFI 进行互操作,FFI 是一种通过 C 动态库的语言绑定方案。我打算将其提交到 iOS App Store。
问题
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
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.
不少SO问题证实了这个问题,例如:
- can I use dynamic library(shared object) in my iphone app?
- Will Appstore reviewers allow us to use dynamic library in iOS8?
然后official flutter documentation说
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.
问题
- 截至我 post 这个 (2020) 的日期,这是否表示我永远无法将使用此架构的应用程序发布到 App Store?
- 是否可以将 link 我的 C/C++ 代码静态化为 flutter 应用程序的单个二进制文件?以Unity为例,their iOS plugin system recompiles the plugin into native app。如果flutter有类似的机制,怎么样?
关于 iOS 不能使用动态库的回答可以追溯到 iOS 8 之前,当时添加了对用户提供的动态库的支持。
在 2.5.2 天内没有任何内容您不能使用动态库,只要它们作为您的应用程序的一部分提供。所以:
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?
不,它不会,只要 "this architecture" 指的是使用您 link 在构建时使用的动态库并将其捆绑到您的应用程序中。
从 Reddit 的 FlutterDev 频道添加输入
@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 Whosebug 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.