Search code examples
kotlinmultiplatformkotlin-multiplatformkotlin-native

Kotlin/Native compileKotlinIosX64 task fails when building iOS app


I have a Kotlin Multiplatform project. I recently updated to Kotlin 1.4-M2 (I need it to solve some issues with Ktor). After updating all the required libraries, resolving all gradle issues and having my Android project compile successfully, I now encounter the following error when building the iOS app:

Task :shared:compileKotlinIosX64
e: Compilation failed: Could not find declaration for unbound symbol org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl@56f11f08
* Source files: [all shared folder kt files]
 * Compiler version info: Konan: 1.4-M2 / Kotlin: 1.4.0
 * Output kind: LIBRARY
e: java.lang.IllegalStateException: Could not find declaration for unbound symbol org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl@56f11f08
    at org.jetbrains.kotlin.ir.util.ExternalDependenciesGeneratorKt.getDeclaration(ExternalDependenciesGenerator.kt:76)

The curious thing is that in Source files it shows all the files in the shared code folder. I checked and absolutely all kt files appear in there. So my guess is that it is some issue when building the shared code, but does not seem specific of any library.

This is a slightly reduced version of how my build.gradle.kts looks like:

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("kotlinx-serialization")
    id("com.android.library")
    id("io.fabric")
}

// CocoaPods requires the podspec to have a version.
version = "1.0"

tasks {
    withType<KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
}

kotlin {
    ios()
    android()

cocoapods {
    // Configure fields required by CocoaPods.
    summary = "Some description for a Kotlin/Native module"
    homepage = "Link to a Kotlin/Native module homepage"
}

sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
                api("org.kodein.di:kodein-di:7.1.0-kotlin-1.4-M3-84")
                implementation("io.mockk:mockk:1.9.2")

                api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")

                api("com.russhwolf:multiplatform-settings:$multiplatformSettingsVersion")

                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-json:$ktorVersion")
                implementation("io.ktor:ktor-client-logging:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization:$ktorVersion")
            }
        }
}
}

And the library versions are as follows:

val ktorVersion = "1.3.2-1.4-M2"
val kotlinVersion = "1.4-M2"
val coroutinesVersion = "1.3.7-native-mt-1.4-M2"
val serializationVersion = "0.20.0-1.4-M2"
val multiplatformSettingsVersion = "0.6-1.4-M2"

It's worth mentioning this was building correctly in iOS when using 1.3.72.


Solution

  • As @KevinGalligan suggested, I updated Kotlin and all related libs to 1.4.0-rc and the problem was solved.

    The root issue with 1.4-M2 remains unknown.