JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.59k stars 1.14k forks source link

IOS build fails because of org.jetbrains.compose.annotation-internal:annotation dependency #4277

Closed binishmatheww closed 5 months ago

binishmatheww commented 5 months ago

I am unable to build my KMP app for IOS. I am getting this error: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/binishmathew/binishmatheww/Kadalas, /Users/binishmathew/.konan/klib, /Users/binishmathew/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/common, /Users/binishmathew/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/platform/ios_simulator_arm64]

My common.gradle: import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins { kotlin("multiplatform") id("com.android.library") id("kotlin-parcelize") kotlin("plugin.serialization") version "1.9.22" id("app.cash.sqldelight") id("dev.icerock.mobile.multiplatform-resources") id("org.jetbrains.compose") version "1.5.12" }

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class) kotlin { kotlin.applyDefaultHierarchyTemplate()

androidTarget {
    kotlin {
        jvmToolchain(19)
    }
}

jvm()

val xcFramework = XCFramework("common")
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64(),
).forEach {
    it.binaries.framework {
        baseName = "common"
        //isStatic = true // Has some issues related to lsqlite3. https://github.com/cashapp/sqldelight/issues/1442
        isStatic = false
        linkerOpts.add("-lsqlite3")
        xcFramework.add(this)
        export(libs.mocko.resources)
        export(libs.mocko.graphics)
        export(libs.decompose)
        export(libs.mvikotlin)
        export(libs.mvikotlin.main)
        export(libs.essenty.lifecycle)
    }
}

sourceSets {
    val commonMain by getting {
        sourceSets["commonMain"].resources.srcDirs("src/commonMain/resources/")
        dependencies {
            api(compose.runtime)
            api(compose.foundation)
            api(compose.material)
            api(libs.kotlinx.coroutines.core)
            api(libs.ktor.client.core)
            api(libs.ktor.client.content.negotiation)
            api(libs.ktor.serialization.kotlinx.json)
            api(libs.sqldelight.runtime)
            api(libs.sqldelight.coroutines.extensions)
            api(libs.kotlinx.datetime)
            api(libs.kotlinx.serialization.json)
            api(libs.mocko.resources)
            api(libs.mocko.resources.compose)
            api(libs.mocko.graphics)
            api(libs.decompose)
            api(libs.decompose.compose)
            api(libs.essenty.lifecycle)
            api(libs.reaktive)
            api("io.coil-kt.coil3:coil:3.0.0-SNAPSHOT")
            api("io.coil-kt.coil3:coil-compose:3.0.0-SNAPSHOT")
            api("io.coil-kt.coil3:coil-network:3.0.0-SNAPSHOT")
            api("com.mohamedrejeb.calf:calf-file-picker:0.3.0")
            api("com.squareup.okio:okio:3.6.0")
        }
    }
    val commonTest by getting {
        dependencies {
            api(kotlin("test"))
            api(libs.mocko.resources.test)
        }
    }
    val nativeMain by getting{
        dependencies {
            api(libs.sqldelight.native.driver)
        }
    }
    val nativeTest by getting {
        dependencies {

        }
    }
    val jvmMain by getting {
        dependsOn(commonMain)
        dependencies {
            api(libs.kotlinx.coroutines.swing)
            api(libs.ktor.client.okhttp)
            api(libs.ktor.client.serialization.jvm)
            api(libs.sqldelight.runtime.jvm)
            api(libs.sqldelight.sqlite.driver)
            api(libs.decompose.jvm)
            api(libs.mocko.resources)
            api(libs.mocko.resources.compose)
        }
    }
    val jvmTest by getting {
        dependencies {
            api(libs.junit)
            api(libs.mocko.resources.test)
        }
    }
    val androidMain by getting {
        dependsOn(commonMain)
        dependencies {
            api(libs.compose.ui)
            api(libs.compose.ui.tooling)
            api(libs.compose.ui.tooling.preview)
            api(libs.compose.foundation)
            api(libs.compose.material)
            api(libs.activity.compose)
            api(libs.ktor.client.android)
            api(libs.sqldelight.android.driver)
            api(libs.mvikotlin.logging)
            api(libs.mvikotlin.timetravel)
            api(project.dependencies.platform("com.google.firebase:firebase-bom:32.4.0"))
            api("com.google.firebase:firebase-messaging")
            api("com.google.firebase:firebase-installations")
        }
    }
    val androidUnitTest by getting {
        dependencies {

        }
    }
    val androidInstrumentedTest by getting {
        dependencies {

        }
    }
    val iosX64Main by getting
    val iosArm64Main by getting
    val iosSimulatorArm64Main by getting
    val iosMain by getting {
        dependsOn(commonMain)
        iosX64Main.dependsOn(this)
        iosArm64Main.dependsOn(this)
        iosSimulatorArm64Main.dependsOn(this)
        dependencies {
            api(libs.ktor.client.darwin)
            api(libs.sqldelight.native.driver)
        }
    }
    val iosTest by getting {
        dependencies {

        }
    }
}

}

android { namespace = "x.y.z" compileSdk = 34 defaultConfig { minSdk = 23 } } dependencies { implementation(libs.androidx.annotation.jvm) }

sqldelight { databases{ create("xyz"){ packageName.set("x.y.z.sqldelight") verifyMigrations = true //dialect("app.cash.sqldelight:postgres-dialect:2.0.1") dialect("app.cash.sqldelight:sqlite-3-24-dialect:2.0.1") } } linkSqlite = true }

Affected platforms Select one of the platforms below:

Versions

dima-avdeev-jb commented 5 months ago

Thanks for this Issue. Can you please provide minimal reproducible sample project on GitHub?

eygraber commented 5 months ago

@dima-avdeev-jb here's a failure in my smallish project due to this https://github.com/eygraber/vice/actions/runs/7893533731

eygraber commented 5 months ago

Actually my error is slightly different (org.jetbrains.compose.collection-internal:collection) and I'm using 1.6.0-rc01 but otherwise same concept.

chrisbanes commented 5 months ago

Seeing the same thing in Tivi. The update to 1.6.0-rc01 is failing with:

Error: error: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/runner/work/tivi/tivi, /Users/runner/.konan/klib, /Users/runner/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/common, /Users/runner/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/platform/ios_arm64]

garretyoder commented 5 months ago

Confirmed here as well after updating to rc01.

igordmn commented 5 months ago

It happens because some library depends on 1.6.0-beta02, which isn't binary compatible with 1.6.0-rc01

Looking at the dependencies of tivi (gradlew shared:common:dependencies), I found:

|    +--- dev.chrisbanes.haze:haze:0.5.1
|    |    +--- org.jetbrains.compose.ui:ui:1.6.0-beta02 -> 1.6.0-rc01 (*)

@chrisbanes, will upgrading dev.chrisbanes.haze:haze:0.5.1 to Compose 1.6.0-rc01 or using the older version that depends on 1.5.12 help?

chrisbanes commented 5 months ago

Ah makes sense. I'm about to upgrade Haze anyway 👌

EDIT: Just released Haze 0.5.2 which seems to have fixed things for consumers.

eygraber commented 5 months ago

I had a similar situation with a dependency. Updated it and the error has gone away.

mahramane commented 5 months ago

Hello I also have the same problem with 1.6.0-rc01 kotlin multiplatform when running ios in fleet IDE. I didn't have this problem with 1.6.0-beta02 and it happened when I updated it to 1.6.0-rc01.

error: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Volumes/Aino/Aino, /Users/mohammad/.konan/klib, /Users/mohammad/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/common, /Users/mohammad/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/platform/ios_simulator_arm64]
Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Volumes/Aino/Aino, /Users/mohammad/.konan/klib, /Users/mohammad/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/common, /Users/mohammad/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.22/klib/platform/ios_simulator_arm64]Compilation finished with errors
igordmn commented 5 months ago

I also have the same problem with 1.6.0-rc01

The solution is to find the dependency that depend on 1.6.0-beta02 and downgrade it or ask the author of the library to upgrade it to 1.6.0-rc01.

Added that to the CHANGELOG.

sureshmaidaragi1919 commented 5 months ago

@dima-avdeev-jb I am also facing the same issue in KMM project

settings.kt plugins


    plugins {
        val firebaseCrashlyticsVersion = extra["firebase.crashlytics.version"] as String
        val googleServicesVersion = extra["google.services.version"] as String

        id("org.jetbrains.compose").version("1.6.0-rc01")
        kotlin("jvm").version("1.9.20")
        kotlin("multiplatform").version("1.9.20")
        kotlin("android").version("1.9.20")
        id("com.android.application").version("8.0.2")
        id("com.android.library").version("8.0.2")
        id("com.google.gms.google-services").version(googleServicesVersion).apply(false)
        id("com.google.firebase.crashlytics").version(firebaseCrashlyticsVersion).apply(false)
    }
MatkovIvan commented 5 months ago

@sureshmaidaragi1919

The solution is to find the dependency that depend on 1.6.0-beta02 and downgrade it or ask the author of the library to upgrade it

okushnikov commented 2 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.