question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kotlin Multiplatform - Kotlin Native IOS Common Code Not building with Ktor Libraries

See original GitHub issue

Ktor 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:checkand 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

  1. 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
agrosnercommented, Jul 30, 2019
0reactions
e5lcommented, Mar 25, 2020

Can’t reproduce it with kotlin 1.3.71 and ktor 1.3.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a cross-platform mobile application - Ktor
In this tutorial, we'll create a simple Kotlin Multiplatform Mobile application, which sends a request and receives a response body as plain HTML...
Read more >
Current issues with Kotlin Multiplatform and how to fix them
Recently I started to play around with Kotlin Multiplatform, ... to be able to write code that is getting shared between Android and...
Read more >
Create a multiplatform app using Ktor and SQLDelight – tutorial
After the project is compiled, the generated Kotlin code will be stored in the shared/build/generated/sqldelight directory. The generator will ...
Read more >
Kotlin/Native compileKotlinIosX64 task fails when building iOS ...
So my guess is that it is some issue when building the shared code, but does not seem specific of any library.
Read more >
Create Your Kotlin Multiplatform Mobile Library
This article provides an overview of the most popular Kotlin Multiplatform Mobile libraries and shed some light on what motivated the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found