Hello everyone,
I want to implement a few use cases before migrating my business logic code from JAVA to Kotlin/Multiplatform.
One of them is using c++ code.
There is an option to use c++ code in Kotlin/Multiplatform project on commonMain level?
Or I need to write a wrapper layer (like JNI) for each platform?
Can I get some example code?
Many thanks!
There is no way to implement a common wrapper (how do you see browser wrapper for example?). If you need to access your C++ code both from JVM and Native, you need to do it two times via expect/actual mechanism.
1 Like
@darksnake
Tnx for your answer!
So what is the best project structure to build a common business logic code for IOS & Android?
It means- what I need for this?
- IntelliJ IDEA (For Kotlin/Multiplatform library) for .aar & .framework
- Android Studio for Android application project
- XCode for IOS application
Once in (1) - the structure will be something like:
- commonMain (‘expect’ annotation)
- iosMain (‘actual’ implementation for c++ bridge - objective c)
- androidMain, JvmMain (‘actual’ implementation for c++ bridge - JNI)
if am I wrong - please let me know.
if am I right - Can I get a reference or some code example of how to actually use the C++ library for each platform? because I’m trying to do it for Android and it does not seem to work.
when I add this:
externalNativeBuild {
cmake {
path file('CMakeLists.txt')
}
}
to my my build.gradle I got “Unsupported method: AndroidArtifact.getBuildConfigFields()” error.