https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
m

Marcos Paulo Farias

02/27/2024, 6:41 AM
Hi everyone, has anyone had this problem?
Copy code
> Task :composeApp:compileKotlinIosSimulatorArm64 FAILED
error: Could not find "org.jetbrains.compose.material:material"
The project run work fine in Android but in iOS there is that problem using compose 1.6.0-rc03
Copy code
import org.jetbrains.compose.ExperimentalComposeLibrary

plugins {
    with(libs.plugins) {
        alias(kotlinMultiplatform)
        alias(androidApplication)
        alias(jetbrainsCompose)
    }
}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
        }
    }

    sourceSets {
        androidMain.dependencies {
//            implementation("com.squareup.sqldelight:android-driver:$sqlDelightVersion")
            with(libs) {
                implementation(ktor.client.android)
                implementation(androidx.activity.compose)
//                implementation(compose.ui.tooling.preview)
            }
        }

        iosMain.dependencies {
            implementation(libs.ktor.client.darwin)
//            implementation("com.squareup.sqldelight:native-driver:$sqlDelightVersion")
        }

        commonMain.dependencies {

            implementation("org.jetbrains.compose.compiler:compiler:1.5.8.1")

            with(compose) {
                implementation(ui)
                implementation(runtime)
                implementation(material3)
                implementation(foundation)
                implementation(materialIconsExtended)

                @OptIn(ExperimentalComposeLibrary::class)
                implementation(components.resources)
            }

            with(libs) {
                implementation(stdlib)
//                implementation(zoomable)

//                with(multiplatformSettings) {
//                    api(core)
//                    api(noArg)
//                    api(coroutines)
//                }
                with(voyager) {
                    implementation(koin)
                    implementation(navigator)
                    implementation(screenModel)
                    implementation(transitions)
                    implementation(tabNavigator)
                    implementation(bottomSheetNavigator)
                }
                with(ktor) {
                    implementation(client.core)
                    implementation(client.content.negotiation)
                    implementation(serialization.kotlinx.json)
                }
                with(coil) {
                    implementation(core)
                    implementation(compose)
                    implementation(network)
                }
//                with(sqldelight) {
//                    implementation(runtime)
//                    implementation(coroutine)
//                }
//                with(kmpalette) {
//                    implementation(core)
//                    with(extensions){
//                        implementation(base64)
//                        implementation(bytearray)
//                        implementation(libres)
//                        implementation(network)
//                        implementation(resources)
//                        implementation(file)
//                    }
//                }
            }
        }
    }
}
Copy code
[versions]
agp = "8.1.4"
android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"
androidx-activityCompose = "1.8.2"
androidx-appcompat = "1.6.1"
androidx-constraintlayout = "2.1.4"
androidx-core-ktx = "1.12.0"
compose = "1.6.1"
compose-plugin = "1.6.0-rc03"
kotlin = "1.9.21"
material3 = "1.2.0"
material-icons= "1.6.0-rc03"
coil = "3.0.0-alpha04"
voyager = "1.0.0"
multiplatformSettings = "1.1.1"
koin-compose = "1.1.2"
kotlinxSerializationJson = "1.6.2"
kotlinxDateTime = "0.5.0"
sqldelight = "2.0.1"
coroutines = "1.8.0-RC2"
ktor = "2.3.8"
zoomable = "1.6.0"
kmpalette = "3.1.0"

[libraries]
stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }

# Third
zoomable = { module = "net.engawapg.lib:zoomable", version.ref = "zoomable" }

androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }

kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
kotlinx-serializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinxSerializationJson" }
kotlinx-dateTime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDateTime" }

# Multiplatform Settings
multiplatformSettings-core = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatformSettings" }
multiplatformSettings-noArg = { module = "com.russhwolf:multiplatform-settings-no-arg", version.ref = "multiplatformSettings" }
multiplatformSettings-coroutines = { module = "com.russhwolf:multiplatform-settings-coroutines", version.ref = "multiplatformSettings" }

# Ktor
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
ktor-client-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor" }
ktor-client-android = { group = "io.ktor", name = "ktor-client-android", version.ref = "ktor" }
ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }

# Coil
coil-core = { module = "io.coil-kt.coil3:coil-core", version.ref = "coil" }
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil" }
coil-network = { module = "io.coil-kt.coil3:coil-network-ktor", version.ref = "coil" }

# Compose
#compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
#compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
#compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
#compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
compose-ui = { module = "org.jetbrains.compose.ui:ui", version.ref = "compose" }
compose-ui-tooling = { module = "org.jetbrains.compose.ui:ui-tooling", version.ref = "compose" }
compose-foundation = { module = "org.jetbrains.compose.foundation:foundation", version.ref = "compose" }
compose-ui-tooling-preview = { module = "org.jetbrains.compose.ui:ui-tooling-preview", version.ref = "compose" }

# Material
material-icons-extended = { module = "org.jetbrains.compose.material:material-icons-extended", version.ref = "material-icons" }
compose-material3 = { module = "org.jetbrains.compose.material:material", version.ref = "material3" }

# Voyager
voyager-koin = { module = "cafe.adriel.voyager:voyager-koin", version.ref = "voyager" }
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
voyager-screenModel = { module = "cafe.adriel.voyager:voyager-screenmodel", version.ref = "voyager" }
voyager-tabNavigator = { module = "cafe.adriel.voyager:voyager-tab-navigator", version.ref = "voyager" }
voyager-bottomSheetNavigator = { module = "cafe.adriel.voyager:voyager-bottom-sheet-navigator", version.ref = "voyager" }

# SQLDelight
sqldelight-runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sqldelight" }
sqldelight-native = { module = "app.cash.sqldelight:native-driver", version.ref = "sqldelight" }
sqldelight-sqlite = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" }
sqldelight-primitive = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sqldelight" }
sqldelight-coroutine = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqldelight" }
sqldelight-paging = { module = "app.cash.sqldelight:androidx-paging3-extensions", version.ref = "sqldelight" }
sqldelight-primitive-adapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sqldelight" }

# KMPalette
kmpalette-core = { module = "com.kmpalette:kmpalette-core", version.ref = "kmpalette" }
kmpalette-extensions-base64 = { module = "com.kmpalette:extensions-base64", version.ref = "kmpalette" }
kmpalette-extensions-bytearray = { module = "com.kmpalette:extensions-bytearray", version.ref = "kmpalette" }
kmpalette-extensions-libres = { module = "com.kmpalette:extensions-libres", version.ref = "kmpalette" }
kmpalette-extensions-network = { module = "com.kmpalette:extensions-network", version.ref = "kmpalette" }
kmpalette-extensions-resources = { module = "com.kmpalette:extensions-resources", version.ref = "kmpalette" }
kmpalette-extensions-file = { module = "com.kmpalette:extensions-file", version.ref = "kmpalette" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "agp" }
androidApplication = { id = "com.android.application", version.ref = "agp" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }

[bundles]
coil = [
    "coil-core",
    "coil-compose",
    "coil-network"
]

voyager = [
    "voyager-koin",
    "voyager-navigator",
    "voyager-screenModel",
    "voyager-transitions",
    "voyager-tabNavigator",
    "voyager-bottomSheetNavigator"
]

sqldelight = [
    "sqldelight-runtime",
    "sqldelight-native",
    "sqldelight-sqlite",
    "sqldelight-primitive",
    "sqldelight-coroutine",
    "sqldelight-paging",
    "sqldelight-primitive-adapters"
]
j

Joel Denke

02/27/2024, 6:44 AM
Copy code
compose-material3 = { module = "org.jetbrains.compose.material:material", version.ref = "material3" }
These lines is wrong 🙂 Also recommend not refer to dynamic resolved things by jetbrains compose plugin, refer to like compose.material3 instead.
All libs refererred in TOML file will be tried to be resolved, hence the issue 🙂
m

Marcos Paulo Farias

02/27/2024, 6:54 AM
Hie Joel, thank you for your reply. Should I remove this line from toml?
j

Joel Denke

02/27/2024, 6:55 AM
I would try that 🙂 Youre using:
Copy code
with(compose) {
                implementation(ui)
                implementation(runtime)
                implementation(material3)
                implementation(foundation)
                implementation(materialIconsExtended)

                @OptIn(ExperimentalComposeLibrary::class)
                implementation(components.resources)
            }
No need to duplicate this 🙂
m

Marcos Paulo Farias

02/27/2024, 7:01 AM
I removed the line from toml and kept in build.gradle.kts. I cleaned the project and it's work in android but I got same error in iOS
Hi there, posting here for future research. I just created a new KMP project and now it's come with 1.60 jetbrains compose plugin and other configs that I didn't have in my older project. I tested material3 and now it's working. I'm going to migrate my project soon.
Thank you for helping Joel
j

Joel Denke

02/27/2024, 8:46 PM
Not sure I helped much, but glad it works :)
h

Hoài An Bùi Lê

03/04/2024, 3:49 AM
This bug happen to me when i replace
compose.material
by
compose.material3
. Add them both and the error gone
35 Views