Hi all I have got an app on both Android and iOS w...
# multiplatform
n
Hi all I have got an app on both Android and iOS which integrates native c/c++ library, I am very much excited to migrate to Kotlin Multiplatform, just wanted to know how to have this integration with Kotlin Multiplatform and also are there any other challenges I need to be aware of before making my decision
e
Kotlin/Native cinterop and Android/Java JNI work very differently and there isn't anything to help you maintain consistency in a multiplatform project now, unfortunately
you can write
expect
in common code, with separate
actual
implementations on Android and iOS
👍 1
n
Will give a try with this first before making a decision, this is crucial for me
j
@Oleg Yukhnevich has been working on multiplatform FFI. Check out: https://github.com/whyoleg/ffi-kotlin https://kotlinlang.slack.com/archives/C3PQML5NU/p1692257703853549
o
Yeah, work in progress still! not for production any time soon 🙃 But current
main
branch more or less shows on how to make it possible to write common code BUT, be aware, that Im researching there GENERAL approach. If you just need to wrap some functions it will be much more easier 🙂 Some time ago, I created another repository (https://github.com/whyoleg/kotlin-interop-playground) where I would to collect some different currently possible ways to integrate native code in different platforms If I will find time, I could try to setup some minimal, simple to check sample for native code sharing in android and iOS with common code - of course if it will be helpful