Hello i found out that many people raise a questio...
# kotlin-native
m
Hello i found out that many people raise a question about the difference between Kotlin/Native and Kotlin-multiplatform, I personally use the plugin multiplatform to target native (android/ios) I'm I doing it right or there is another plugin to use just for native target?
k
I think native is for everything excluding jvm and js. iOS is part of native. Jvm, ios, etc are all part of multiplatform. I think you are doing right.
Kotlin docs have separation for common (aka core), jvm, native and js. E.g. some classes/methods available only on specific target.
m
So basically it's just naming? when I tell someone I use Kotlin/Native it's to tell him I'm using the plugin Multiplatform to target Native (IOS and Android) and when i say I use Kotlin Multiplatform it's the same plugin but targeting JVM/JS?
k
You could use KN without MPP,and you could use MPP without KN 😄
KN is about what klind of artifacts are build (e.g. .framework). MPP is about how project sources and dependencies are structured.
m
I used to make my project from scratch without generating project with IntelliJ and add targets in my build.gradle
maybe that's why I'm confused
You said that "KN is about what kind of artifacts are build" but dont you need to structure sources and dependencies (androidMain, iosMain etc ...) and by doing so doing MPP?
even in the Kotlin/Native tutorial https://play.kotlinlang.org/hands-on/Introduction%20to%20Kotlin%20Native/02_CreatingAProject they use kotlin-multiplatform and define sourcesets
k
I think MPP is default way to create project that targets multiple platforms.
E.g. you could create project without MPP, that will be compiled to jvm and ios (.framework).
it will use only compilation part from KN, but will not use any platform specific code (e.g. io/workers/couroutines will not be available)
In that case, you will have just main (similar to pure java projects).
If there are multiple sources, then yes - it is MPP.
k
kotlin multiplatform allows you to build multiple targets from the same set of sources, with some platform specific implementations. K/N enables that (as does kotlin JVM and kolin JS)
but I believe that JB sees most of the use cases for K/N coming from multiplatform, and so the "line" maybe gets blurry
g
I don't think that K/N is exclusively or even mostly for MPP, I believe both use cases are equally important
m
Well, it's just
kotlin-platform-native
Gradle plugin was deprecated in favor of
kotlin-multiplatform
. But if someone absolutely want - K/N can be used from command line without Gradle, via
konanc
, just like
javac