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

Hannes

12/01/2019, 7:31 PM
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

louiscad

12/01/2019, 7:34 PM
You need to depend on the native artifact in commonMain.
h

Hannes

12/01/2019, 7:36 PM
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

louiscad

12/01/2019, 7:43 PM
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

Hannes

12/01/2019, 7:46 PM
ah, thanks
m

mbonnin

12/01/2019, 10:04 PM
Is it just me or that feels quite unintuitive ? Common shouldn't know anything about native, right ?
l

louiscad

12/02/2019, 2:04 AM
The naming of the artifact, yes, but it's like that for historical reasons and will change sometime.
👍 1
2 Views