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

Aleksey Chugaev

12/13/2019, 9:48 PM
Hi All, I am trying to use mt coroutines in my project but cannot resolve
newSingleThreadContext
in iosMain • I have built https://github.com/Kotlin/kotlinx.coroutines/tree/native-mt and installed it locally • added
kotlin.mpp.enableGranularSourceSetsMetadata=true
to gradle.properties • commonMain depends on
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2-native-mt-SNAPSHOT"
• iosMain depends on
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.2-native-mt-SNAPSHOT"
• using kotlin 1.3.61 Am I missing something? P.S. I have also tried to build https://github.com/kpgalligan/MTCoroutines locally and it worked.
k

kpgalligan

12/13/2019, 10:10 PM
newSingleThreadContext
isn’t available in common code. I think, anyway. You’d need to expect/actual.
a

Aleksey Chugaev

12/13/2019, 10:12 PM
This is what you have in your project (iosMain):
Copy code
import kotlinx.coroutines.newSingleThreadContext

@SharedImmutable
actual val workerDispatcher: CoroutineDispatcher = newSingleThreadContext("mr background")
I have copied it to my project but cannot resolve
kotlinx.coroutines.newSingleThreadContext
k

kpgalligan

12/13/2019, 10:13 PM
Ah. Do you have
mavenLocal()
in the repos list?
a

Aleksey Chugaev

12/13/2019, 10:15 PM
yes, it can resolve other coroutines classes
k

kpgalligan

12/13/2019, 10:16 PM
Well, without seeing your code, then you’re maybe pulling in a different coroutines version from another transitive dependency
a

Aleksey Chugaev

12/13/2019, 10:36 PM
Good point, I will check other dependencies
Turns out ktor 1.3.0-beta-2 was overriding coroutines dependencies with 1.3.2-1.3.60
👆 1
2 Views