Kotlin Multiplatform - Kotlin Native IOS Common Code Not building with Ktor Libraries
See original GitHub issueKtor Version and Engine Used (client or server and name) 1.2.2, 1.2.0, 1.2.3-rc all tested Gradle Version: 5.5 Kotlin Version 1.3.41
Describe the bug
I have a Kotlin multiplatform library (not application) with targets on Android, IOS, and JS web. The project contains a subproject called lib
and another subproject codegen
.
I run ./gradlew :lib:check
and Android and JS are working great.
On IOS I receive this error on compiling when I add a iosTest
directory and adding a test so it gets compiled:
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (3, 8): Unresolved reference: io
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (4, 8): Unresolved reference: io
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (5, 8): Unresolved reference: io
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (6, 8): Unresolved reference: io
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (20, 41): Unresolved reference: HttpClient
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (20, 41): Unresolved reference: HttpClient
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (20, 54): Unresolved reference: HttpClient
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (21, 25): Unresolved reference: install
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (21, 33): Unresolved reference: JsonFeature
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (22, 29): Unresolved reference: serializer
[system.err] e: /$path/lib/src/commonMain/kotlin/$package/Lexicographer.kt: (22, 42): Unresolved reference: KotlinxSerializer
It seems as though the common code is not compiling for Ktor from Kotlin Native IOS. If I remove the problematic code (but keep around other code such as kotlinx.serialization and kotlinx.coroutines) then the project will compile.
I have tried adding more ios specific dependencies to ios project and other artifacts shown in the dependencies of other ktor projects, to no luck.
To Reproduce
- Attempt to compile using
./gradlew :lib:check
Expected behavior IOS can build.
I’ve attached dependencies for reference and to note Ive added enableFeaturePreview("GRADLE_METADATA")
to my settings.gradle.
iosArm64-api (n)
+--- io.ktor:ktor-client-serialization-iosarm64:1.2.3-rc (n)
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41 (n)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-RC (n)
+--- io.ktor:ktor-client-core:1.2.3-rc (n)
+--- io.ktor:ktor-client-serialization:1.2.3-rc (n)
+--- io.ktor:ktor-client-json:1.2.3-rc (n)
+--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.1 (n)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.0-RC (n)
+--- io.ktor:ktor-client-ios:1.2.3-rc (n)
+--- io.ktor:ktor-client-json-native:1.2.3-rc (n)
+--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.11.1 (n)
\--- org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.0-RC (n)
iosArm64Api - API dependencies for compilation 'main' (target iosArm64 (native)).
+--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-RC
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.41
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | \--- org.jetbrains:annotations:13.0
| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
+--- io.ktor:ktor-client-core:1.2.3-rc
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC
| | \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | \--- org.jetbrains.kotlinx:atomicfu-common:0.12.9
| +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | +--- org.jetbrains.kotlinx:atomicfu-common:0.12.9
| | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| +--- io.ktor:ktor-http:1.2.3-rc
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | \--- io.ktor:ktor-utils:1.2.3-rc
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| \--- io.ktor:ktor-http-cio:1.2.3-rc
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| \--- io.ktor:ktor-http:1.2.3-rc (*)
+--- io.ktor:ktor-client-serialization:1.2.3-rc
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| +--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.1
| | \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.40 -> 1.3.41
| \--- io.ktor:ktor-client-json:1.2.3-rc
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| \--- io.ktor:ktor-client-core:1.2.3-rc (*)
+--- io.ktor:ktor-client-json:1.2.3-rc (*)
+--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.1 (*)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.0-RC (*)
+--- io.ktor:ktor-client-serialization-iosarm64:1.2.3-rc
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| +--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.1 (*)
| +--- io.ktor:ktor-client-json-iosarm64:1.2.3-rc
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | +--- io.ktor:ktor-client-core-iosarm64:1.2.3-rc
| | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | | +--- io.ktor:ktor-http-iosarm64:1.2.3-rc
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | | | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | | | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | | | +--- io.ktor:ktor-utils-iosarm64:1.2.3-rc
| | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | | | | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | | | | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | | | | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9
| | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.40 -> 1.3.41
| | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2
| | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.40 -> 1.3.41
| | | | | | \--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | | | | +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12
| | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | | | | | +--- org.jetbrains.kotlinx:atomicfu-common:0.12.9
| | | | | | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | | | | | \--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | | | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io-iosarm64:0.1.12
| | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | | | | +--- org.jetbrains.kotlinx:atomicfu-common:0.12.9
| | | | | +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12 (*)
| | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | | | | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2 (*)
| | | | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | | | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2 (*)
| | | | +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12 (*)
| | | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io-iosarm64:0.1.12 (*)
| | | +--- io.ktor:ktor-http-cio-iosarm64:1.2.3-rc
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
| | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.2 -> 1.3.0-RC (*)
| | | | +--- org.jetbrains.kotlinx:kotlinx-io:0.1.12 (*)
| | | | +--- org.jetbrains.kotlinx:atomicfu:0.12.9
| | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-io:0.1.12 (*)
| | | | +--- io.ktor:ktor-http-iosarm64:1.2.3-rc (*)
| | | | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2 (*)
| | | | +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12 (*)
| | | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io-iosarm64:0.1.12 (*)
| | | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2 (*)
| | | +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12 (*)
| | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io-iosarm64:0.1.12 (*)
| | +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2 (*)
| | +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12 (*)
| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-io-iosarm64:0.1.12 (*)
| +--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-iosarm64:0.11.1
| | \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.40 -> 1.3.41
| +--- org.jetbrains.kotlinx:atomicfu-iosarm64:0.12.9 (*)
| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core-iosarm64:1.2.2 (*)
| +--- org.jetbrains.kotlinx:kotlinx-io-iosarm64:0.1.12 (*)
| \--- org.jetbrains.kotlinx:kotlinx-coroutines-io-iosarm64:0.1.12 (*)
+--- io.ktor:ktor-client-ios:1.2.3-rc
+--- io.ktor:ktor-client-json-native:1.2.3-rc
+--- org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.11.1
\--- org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.0-RC
And in theory this should work. I cannot find a solution to this problem.
Let me know if you need more information
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
here is a working example @e5l https://github.com/agrosner/kotlin-multiplaform-bug-example
Can’t reproduce it with kotlin
1.3.71
and ktor1.3.2
.