https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

Napa Ram

05/11/2021, 6:23 AM
Hello everyone, can anyone explain why do we need to add library separately in androidMain and iosMain and then commonMain, can't we add at once in commonMain and use it for ios and android both
j

Joost Klitsie

05/11/2021, 6:24 AM
I think since kotlin 1.4 you only have to add libraries to common main if it is a multiplatform library.
n

Napa Ram

05/11/2021, 6:27 AM
i was going though https://github.com/kotlin-hands-on/kmm-networking-and-data-storage kotlin hands for kmm they added ktor and sqldelight library in all platform like in commonMain, androidMain and in iosMain also
can we add only once in commonMain then use it for platform specific also
j

Joost Klitsie

05/11/2021, 6:33 AM
Nope that is not what is happening
Ktor core and sqldelight runtime are the libraries and they are only added to the common sourceset
Ktor-android is an extra package with helper functions for android
So that only has value on android.
n

Napa Ram

05/11/2021, 6:35 AM
okay then same way for ios also right
j

Joost Klitsie

05/11/2021, 6:35 AM
I think it counts for the other platform specific implementations as well
n

Napa Ram

05/11/2021, 6:36 AM
thanks @Joost Klitsie
j

Joost Klitsie

05/11/2021, 6:37 AM
You are welcome, it is not as straightforward as they make it sound :)
5 Views