Hi, I was wondering if anyone had to work with kot...
# multiplatform
s
Hi, I was wondering if anyone had to work with kotlin multiplatform and j2objc in one project. The current shared code stack of our projects is mainly j2objc, but we would like to move it slowly towards kmp. Is there a way to have both cores communicate with each other (or at least communicating one-way)?
s
iOS kmp modules can depend on frameworks via the cinterop tool. They can also use CocoaPods. I don’t know anything about j2objc’s external dependency mechanism but if it can call a framework on iOS, then that’s another strategy. Build the kmp iOS framework and let your j2objc code call it. Two-way communication is possible if you’re talking about passing interfaces and callbacks I imagine. Again, I’m not a j2objc person so don’t know for sure.
k
This is pretty old now, but j2objc + KMP was one of the first things I did with KMP. Published anyway. We were working on a whole ecosystem for J2objc at the time, so it kind of made sense. Kotlin/Native is like Kotlin/JVM without the JRE, and J2objc is basically the JRE on iOS, so it seemed like they’d be a good match. However, the interfaces don’t align quite right, so you wind up needing to write glue code. https://medium.com/@kpgalligan/sqlite-sqldelight-%EF%B8%8F-kotlin-multiplatform-f24fe7cba338
Having said that, yes, totally doable.