Hi, I'm new to kotlin multiplatform and I want to ...
# multiplatform
h
Hi, I'm new to kotlin multiplatform and I want to create a multiplatform library using coroutines and
Flow
. Is there any material how to get started with that? I looked into existing multiplaform libraries configs on github and copied most
build.gradle
config but I get a lot of
unresolved reference
errors while compiling:
library/src/commonMain/kotlin/com/freeletics/flowredux/FlowRedux.kt: (7, 32): Unresolved reference: Flow
l
You need to depend on the native artifact in commonMain.
h
I'm including
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2"
. Is there another "native artifact"?
Ah, it looks like
org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.2
works, thanks for your help @louiscad
Is
'org.jetbrains.kotlin:kotlin-stdlib-common'
the proper artifact to include in
commonMain
or is there another "native artifact" for stdlib I have to use?
l
Yes, with
native
in place of
common
, and it works for Android too, because it holds all the Gradle metadata (Gradle 5.3+ required) that links to the right artifacts for each supported platform. You just have to declare it for commonMain. Note that 1.3.2 is Kotlin/Native 1.3.50 only. Use
1.3.2-1.3.60
or
1.3.2-native-mt-1
for Kotlin/Native 1.3.60.
Kotlin/Native stdlib is included by the compiler, no dependency to declare.
h
ah, thanks
m
Is it just me or that feels quite unintuitive ? Common shouldn't know anything about native, right ?
l
The naming of the artifact, yes, but it's like that for historical reasons and will change sometime.
👍 1