Issue with C++ Pod framework
farfromrefug opened this issue · comments
I am trying to use OpenCV Pod.
I do that within nativescript-opencv
So the first thing is getting access to the typings.
The framework has no module.modulemap
so i add it using a hook. Here is the module.modulemap i copy.
Then i run TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios --bundle
in the demo-vue
folder. I end up with OpenCV
typings.
The issue is that the typings are only partial, and i dont know / understand why i have what i have.
I see reading this that it might not work as OpenCV framework is C++ only. But i am still not 100% sure what's happening and would love to have your insight
the demo-vue
works on iOS and finds CV_BGR2HSV_FULL
which is an enum declared in a header file.
So i need to create wrapper Objective-c class for every C class / function i want to use?
Hi @farfromrefug, you probably meant to link to this question: https://www.nativescript.org/faq/can-i-reuse-c-libraries.
And yes, you've correctly understood that in order to call methods from C++ classes you'll have to write C/Objective-C wrappers around them.
Global functions, variables, enums, etc. can be used directly because they are a part of the C subset of C++ and as such are supported by iOS runtime's metadata generator.
Global functions, variables, enums, etc. can be used directly because they are a part of the C subset of C++ and as such are supported by iOS runtime's metadata generator.
That s what i needed to understand!
I get it and am already working on this. I could use a little bit of your help though. Have you any experience with using swig to create objective-c bindings from c++?
Unfortunately, we don't have any experience with swig, but looking at it I couldn't find anything mentioned for Objective-C support.
On the other hand, I found https://github.com/dropbox/djinni which seems to be created just for that job -- to quote the README:
We at Dropbox use Djinni to interface cross-platform C++ library code with platform-specific Java and Objective-C on Android and iOS.
@mbektchiev thanks will take a look at it. I think swig can do it still. I know of Carto Mobile SDK which does this.
Will need to take a look at this.
Thanks