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)?
02/26/2020, 1:55 PM
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.
02/26/2020, 3:11 PM
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