Hello i'm trying to define what is the different kotlin native use case in mobile development and i need to know if it is correct if i say that "kotlin native can be used in 2 ways the first one by creating shared library (.aar and .framework) for a code reuse purpose and the second way is to use it inside a project but still need to create a library to use it in ios side" ?
s
Sam
06/27/2019, 3:04 PM
Kotlin Native can produce both native libraries and native executables for Android and iOS. Not many people use K/N for Android because that means either working with JNI bindings for libraries or using the NDK. Most people use multiplatform and create common libraries usable from the Android and iOS sides. Similarly, on iOS most people use Kotlin/Native in a framework and call into it from Swift/ObjC code, It is possible to produce a pure Kotlin iOS app but it is less practical than the Swift app/Kotlin framework approach.
💯 1
m
mben
06/27/2019, 3:16 PM
So for now for exemple for a client i can say that we can use it either to build shared library for code reuse purpose and push it in a bintray and cocapods or use it internally inside an android/ios project for a single use (only for a specific project)?
r
russhwolf
06/27/2019, 3:35 PM
If it's a small project you don't even need to publish anything externally. Can just have separate gradle modules for shared code, android app code, and an xcode project for iOS
s
Sam
06/27/2019, 3:51 PM
I wouldn't publish a Kotlin Native framework to cocoapods because there can only be one inside of an app. The moment a project needs a second kotlin framework it would require a lot of extra work. The preferred method of code sharing in K/N is using klibs and bintray.