2

I am working on a Flutter plugin that uses OpenCV to perform image processing for both Android and iOS.

Having followed the official tutorial on binding to native code using dart:ffi and followed this answer on how to use OpenCV 4 in native C++ of Flutter I have a plugin that can be called by a Flutter app and perform OpenCV image processing on Android and I am able to successfully call to, and retrieve the correct results form, my C++ functions, which use OpenCV, when testing the plugin on iOS.

When I call these same functions from a Flutter app on iOS that use the plugin I get the error "Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, ): symbol not found)".

I believe that this issue may be related to an issue noted in this Medium article on Using FFI on Flutter to run native Rust code, in which it suggests:

"XCode will not bundle the library unless it detects explicit usage within the workspace. Since our Dart code calling it is out of the scope of XCode, we need to write a dummy Swift function that makes some fake usage."

I have tried to create a dummy Swift function as suggested above in ios/Classes/.swift but the function is not recognised and the build fails with the error "use of unresolved identifier '<my C++ function name>'".

Wildebeest
  • 21
  • 2

0 Answers0