When using Ktor `2.0.0-beta-1` with kotlinx.corout...
# ktor
t
When using Ktor
2.0.0-beta-1
with kotlinx.coroutines
1.6.0-native-mt
I get the following stack trace. When using kotlinx.coroutines
1.5.2-native-mt
with the same Ktor version there are no errors. Using Kotlin
1.6.10
. Any idea what is going wrong?
Copy code
> Task :common:root:linkCommonDebugFrameworkIosArm64
e: Module "io.ktor:ktor-network" has a reference to symbol kotlinx.coroutines/SingleThreadDispatcher|null[0]. Neither the module itself nor its dependencies contain such declaration.

This could happen if the required dependency is missing in the project. Or if there is a dependency of "io.ktor:ktor-network" that has a different version in the project than the version that "io.ktor:ktor-network" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.
Full error from Xcode:
Copy code
Showing Recent Issues
> Task :common:root:linkCommonDebugFrameworkIosArm64

e: Module "io.ktor:ktor-network" has a reference to symbol kotlinx.coroutines/SingleThreadDispatcher|null[0]. Neither the module itself nor its dependencies contain such declaration.



This could happen if the required dependency is missing in the project. Or if there is a dependency of "io.ktor:ktor-network" that has a different version in the project than the version that "io.ktor:ktor-network" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.



The list of "io.ktor:ktor-network" dependencies that may lead to conflicts:

 1. "io.ktor:ktor-io" (a library with unknown version)

 2. "io.ktor:ktor-network-cinterop-network" (a library with unknown version)

 3. "io.ktor:ktor-utils" (a library with unknown version)

 4. "stdlib: 1.6.10" (was initially compiled with "stdlib: 1.6.0")

 5. "org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.0")

 6. "org.jetbrains.kotlin.native.platform.darwin: 1.6.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.darwin: 1.6.0")

 7. "org.jetbrains.kotlin.native.platform.iconv: 1.6.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.iconv: 1.6.0")

 8. "org.jetbrains.kotlin.native.platform.posix: 1.6.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.posix: 1.6.0")

 9. "org.jetbrains.kotlinx:atomicfu" (a library with unknown version)

10. "org.jetbrains.kotlinx:atomicfu-cinterop-interop" (a library with unknown version)

11. "org.jetbrains.kotlinx:kotlinx-coroutines-core" (a library with unknown version)



Project dependencies:

\--- io.ktor:ktor-network

     ^^^ This module requires symbol kotlinx.coroutines/SingleThreadDispatcher|null[0].

     +--- io.ktor:ktor-io

     |    +--- stdlib: 1.6.0 -> 1.6.10

     |    +--- org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.0 -> 1.6.10

     |    |    +--- stdlib: 1.6.10

     |    |    +--- org.jetbrains.kotlin.native.platform.darwin: 1.6.10

     |    |    |    +--- stdlib: 1.6.10

     |    |    |    \--- org.jetbrains.kotlin.native.platform.posix: 1.6.10

     |    |    |         \--- stdlib: 1.6.10

     |    |    \--- org.jetbrains.kotlin.native.platform.posix: 1.6.10 (*)

     |    +--- org.jetbrains.kotlin.native.platform.darwin: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlin.native.platform.iconv: 1.6.0 -> 1.6.10

     |    |    +--- stdlib: 1.6.10

     |    |    \--- org.jetbrains.kotlin.native.platform.posix: 1.6.10 (*)

     |    +--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlinx:atomicfu

     |    |    +--- stdlib: 1.6.0 -> 1.6.10

     |    |    +--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     |    |    \--- org.jetbrains.kotlinx:atomicfu-cinterop-interop

     |    |         +--- stdlib: 1.6.0 -> 1.6.10

     |    |         \--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlinx:atomicfu-cinterop-interop (*)

     |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core

     |         +--- stdlib: 1.6.0 -> 1.6.10

     |         +--- org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.0 -> 1.6.10 (*)

     |         +--- org.jetbrains.kotlin.native.platform.darwin: 1.6.0 -> 1.6.10 (*)

     |         +--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     |         +--- org.jetbrains.kotlinx:atomicfu (*)

     |         \--- org.jetbrains.kotlinx:atomicfu-cinterop-interop (*)

     +--- io.ktor:ktor-network-cinterop-network

     |    +--- stdlib: 1.6.0 -> 1.6.10

     |    \--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     +--- io.ktor:ktor-utils

     |    +--- io.ktor:ktor-io (*)

     |    +--- stdlib: 1.6.0 -> 1.6.10

     |    +--- org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlin.native.platform.darwin: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlin.native.platform.iconv: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     |    +--- org.jetbrains.kotlinx:atomicfu (*)

     |    +--- org.jetbrains.kotlinx:atomicfu-cinterop-interop (*)

     |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)

     +--- stdlib: 1.6.0 -> 1.6.10

     +--- org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.0 -> 1.6.10 (*)

     +--- org.jetbrains.kotlin.native.platform.darwin: 1.6.0 -> 1.6.10 (*)

     +--- org.jetbrains.kotlin.native.platform.iconv: 1.6.0 -> 1.6.10 (*)

     +--- org.jetbrains.kotlin.native.platform.posix: 1.6.0 -> 1.6.10 (*)

     +--- org.jetbrains.kotlinx:atomicfu (*)

     +--- org.jetbrains.kotlinx:atomicfu-cinterop-interop (*)

     \--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)



(*) - dependencies omitted (listed previously)



> Task :common:root:linkCommonDebugFrameworkIosArm64 FAILED
r
Afaik Ktor hasn't been updated to use coroutines 1.6.0 yet, either in beta or release. I think your best bet is to keep using coroutines 1.5.2, but I'm not sure how that works with Kotlin 1.6.10
t
Maybe, as the normal 1.6.0 coroutines version doesn’t work either. It seems to work fine with 1.5.2-native-mt, at least the previous snapshots did.
However, 2.0.0-beta-1 should support the new native memory model, too. Not sure how to try that out if I cannot use coroutines 1.6.0 where support was added.
j
Not a direct answer but fwiw I'm using Ktor
2.0.0-beta-1
with Kotlinx Coroutines
1.6.0
and with new Kotlin/Native memory model enabled.....might perhaps be an option?
example of that combination in https://github.com/joreilly/PeopleInSpace
t
Thanks, that’s interesting, I did try coroutines
1.6.0
but it failed with the same error. Still fails after adding the new MM stuff to gradle.properties, too.
It seems like something is incompatible with ktor-network 2.0.0-beta-1 and coroutines 1.6.0(-native-mt)
j
have you tried 1.6.0 with new k/n memory model enabled?
t
If by 1.6.0 you mean coroutines, yes, same error
j
with new k/n memory model enabled?
i.e. following in
gradle.properties
Copy code
kotlin.native.binary.memoryModel=experimental
t
Yes, I tried that
Still the same error when building from xcode
j
Only thing I can suggest is perhaps try PeopleInSpace and compare settings
t
Well I use ktor-network which I think your project doesn't use by taking a quick look, is that right?
j
one other thing that might be worth trying is using
isForce
like following
Copy code
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.kotlinCoroutines}") {
    isForce = true
}
t
The error I am getting mentions the issue is in ktor-network
j
ah, ok....maybe
t
Already forcing coroutines version everywhere
Thanks for the suggestions, I do appreciate the help.
s
Just ran into this. @John O'Reilly I think the difference here is that both @Thomas and I are trying to use
macosArm64
whereas PeopleInSpace is still using
macosX64
.
t
Well actually I am building for iosArm64. But I do use an M1 mac to build it.
Are you using
ktor-network
? Because that’s where the error comes from for me as you can see in the error logs.
s
transitively, yes! I'm using
ktor-server-cio
which is in turn dependent on
ktor-network
hmmm then I wonder if it's happening because both of us are building on an M1 mac. what about you joe?
I just noticed that your original message is 2 weeks old. were you able to find any workaround?
t
No workaround, but I haven’t looked into it further as I have been busy. For now I am just using coroutines
1.5.2-native-mt
which seems to work fine.
I thinks its just an incompatibility and we would need to wait for Ktor to update to coroutines 1.6.0(-native-mt)
Found the following where they are dropping support for native-mt and they are upgrading coroutines to 1.6.0: https://github.com/ktorio/ktor/pull/2739
I am just going to wait for that and hope that the new memory model works for me, have not been able to test it yet on my project.
s
gotcha, yeah
1.5.2-native-mt
seems to be working fine. I'll continue using this, thank you!
j
@Thomas curious if you got chance to try new memory model?
h
Hm, what about downgrade to Ktor 1.6.7? This version works with coroutines 1.6.0-mt on iOS, see my playground app https://github.com/hfhbd/ComposeTodo
t
@John O'Reilly no as I cannot use coroutines 1.6.0 with Ktor. Or is there another way?
@hfhbd I am using Ktor 2.0.0 features like the UDP native sockets I contributed so unfortunately I cannot use 1.6.7.
j
I could be misunderstanding issue (or perhaps as mentioned above this is related to different target) but I'm using following combination in https://github.com/joreilly/PeopleInSpace/blob/main/buildSrc/src/main/java/Dependencies.kt along with using new memory model
Copy code
const val kotlinCoroutines = "1.6.0"
const val ktor = "2.0.0-beta-1"
t
Yes but that combination doesn't work for me, I get the error mentioned. Probably because of an incompatibility with ktor-network.
j
ah, forgot you had mentioned that before....when I get a chance I'll try to add
ktor-network
to that project and see if I can reproduce
h
Ktor 2.0.0 with 1.6.0 (without mt) is not yet supported, until https://github.com/ktorio/ktor/pull/2739
j
Hmm, that combination seems to be working here