Error with framework in cordova plugin


I’m encountering an issue with one of our plugins that has a dependency on opencv2.framework.

In the plugin.xml file, I have:

<framework src="src/ios/Frameworks/opencv2.framework" custom="true" />

During compilation, I’m seeing the following errors:

…/ios/capacitor-cordova-ios-plugins/sources/CordovaPluginScor/src/ios/Frameworks/opencv2.framework/Versions/Current/Headers/flann/allocator.h:40:1 Unknown type name ‘namespace’

…/ios/capacitor-cordova-ios-plugins/sources/CordovaPluginScor/src/ios/Frameworks/opencv2.framework/Headers/core/base.hpp:49:4 Base.hpp header must be compiled as C++

…/ios/capacitor-cordova-ios-plugins/sources/CordovaPluginScor/src/ios/Frameworks/opencv2.framework/Versions/Current/Headers/calib3d/calib3d_c.h:47:10 Include of non-modular header inside framework module ‘CordovaPlugins.calib3d_c’: ‘…/ios/capacitor-cordova-ios-plugins/sources/CordovaPluginScor/src/ios/Frameworks/opencv2.framework/Headers/core/core_c.h’

However, I’ve found a workaround to make it work:

  1. I remove the line in the plugin.xml:
    <framework src="src/ios/Frameworks/opencv2.framework" custom="true" />
  2. I drag and drop the framework into the Pods > Frameworks directory.
  3. build in Xcode.

This allows the build to proceed correctly, and the plugin works as intended.

However, when I use ionic cap build/run/sync, the framework gets removed, causing issues with launching builds from the command line.

I’m looking for a clean solution to solve this problem.

Thank you in advance.

1 Like