Hello i'm trying to define what is the different k...
# kotlin-native
m
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
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
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
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
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.
The devs from IceRock have a couple nice case study write ups on their use of Kotlin Multiplatform. Part 1 is from the earlier days of K/N and MPP and those problems are mostly solved. Part 2 has more recent experience. https://medium.com/@icerock/the-dos-and-donts-of-mobile-development-with-kotlin-multiplatform-part-ii-d318dae8475b
👍 2
m
Thank you for your feed back
@Sam the last article you shared answered clearly all my questions very interesting one.
👍 1