Hi, Everyone. I usually face this issue on the ios...
# compose-ios
k
Hi, Everyone. I usually face this issue on the ios App while working with Compose Multiplatform. I tried to resolve this error but unable too. I already provided the koin injection code inside the
Copy code
/Users/zohaibkhan/Downloads/Youtube-Clone-KMP-master 9/composeApp/src/iosMain/kotlin/main.kt
But still get this error, I'm unable to run ios Application due to this. Is there any solutions for this?
Copy code
ERROR: No Such Module 'ComposeApp'
p
Are you using cocoapods Khubaib?
k
No, I'm not using that. Do i need to use them?
p
No need for cocoapods unless you need it, there was another thread where someone reported the same and was due to a cocoapods step missing in the settings.
k
How can I resolve this? Do you have any suggestions?
p
It seems that you have a dependency that is not compatible with others.
Copy code
e: KLIB resolver: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/*/ws-kmp/Youtube-Clone-KMP/composeApp, /Users/*/.konan/klib, /Users/*/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.0/klib/common, /Users/*/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.0/klib/platform/ios_simulator_arm64]
I compile it and get this
k
I'm not using any incompatibles dependencies:
Copy code
[versions]

core = "12.1.0"
ffmpegPlatform = "4.1-1.4.4"
kotestProperty = "5.3.1"
kotlin = "2.0.0"
agp = "8.2.2"
compose = "1.6.11"
androidx-appcompat = "1.7.0"
androidx-activityCompose = "1.9.0"
compose-uitooling = "1.6.7"
libres = "1.2.2"
media3Ui = "1.3.1"
media3ExoplayerDash = "1.3.1"
media3Exoplayer = "1.3.1"
vlcj = "4.7.0"
voyager = "1.1.0-beta02"
composeImageLoader = "1.7.8"
napier = "2.7.1"
buildConfig = "5.3.5"
kotlinx-coroutines = "1.8.1"
ktor = "2.3.11"
composeIcons = "1.1.0"
kotlinx-serialization = "1.6.3"
kotlinx-datetime = "0.6.0"
koin = "3.5.4"
kamelImage = "0.9.5"
size = "0.5.0"
sqlDelight = "2.0.2"
glace-effect = "1.0.0"


[libraries]
androidx-glance-app-widget = {module = "androidx.glance:glance-appwidget", version.ref = "glace-effect"}
androidx-glance-material3 = {module = "androidx.glance:glance-material3", version.ref = "glace-effect"}
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "media3Ui" }
androidx-media3-exoplayer-dash = { module = "androidx.media3:media3-exoplayer-dash", version.ref = "media3ExoplayerDash" }
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3Exoplayer" }
compose-uitooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose-uitooling" }
core = { module = "com.pierfrancescosoffritti.androidyoutubeplayer:core", version.ref = "core" }
custom-ui = { module = "com.pierfrancescosoffritti.androidyoutubeplayer:custom-ui", version.ref = "core" }
ffmpeg-platform = { module = "org.bytedeco.javacpp-presets:ffmpeg-platform", version.ref = "ffmpegPlatform" }
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotestProperty" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
libres = { module = "io.github.skeptick.libres:libres-compose", version.ref = "libres" }
vlcj = { module = "uk.co.caprica:vlcj", version.ref = "vlcj" }
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
composeImageLoader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "composeImageLoader" }
napier = { module = "io.github.aakira:napier", version.ref = "napier" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
composeIcons-fontAwesome = { module = "br.com.devsrsouza.compose.icons:font-awesome", version.ref = "composeIcons" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
io-ktor-ktor-client-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
kamel-image = { module = "media.kamel:kamel-image", version.ref = "kamelImage" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
voyager-tab-navigator = { module = "cafe.adriel.voyager:voyager-tab-navigator", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
screen-size = { module = "dev.chrisbanes.material3:material3-window-size-class-multiplatform", version.ref = "size" }
sqlDelight-driver-sqlite = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqlDelight" }
sqlDelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqlDelight" }
sqlDelight-driver-native = { module = "app.cash.sqldelight:native-driver", version.ref = "sqlDelight" }
sqlDelight-driver-js = { module = "app.cash.sqldelight:web-worker-driver", version.ref = "sqlDelight" }
sqlDelight-extension = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqlDelight" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }


[plugins]

multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
android-application = { id = "com.android.application", version.ref = "agp" }
libres = { id = "io.github.skeptick.libres", version.ref = "libres" }
buildConfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildConfig" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
sqlDelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
Build.gradle
Copy code
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
    alias(libs.plugins.multiplatform)
    alias(libs.plugins.compose)
    alias(libs.plugins.android.application)
    alias(libs.plugins.libres)
    alias(libs.plugins.buildConfig)
    alias(libs.plugins.kotlinx.serialization)
    alias(libs.plugins.sqlDelight)
    alias(libs.plugins.compose.compiler)
    id("com.google.osdetector") version "1.7.3"
}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "19"
            }
        }
    }
    jvm()
    js {
        browser()
        binaries.executable()
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
            // Required when using NativeSQLiteDriver
            linkerOpts.add("-lsqlite3")
        }
    }

    sourceSets {
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.material3)
            implementation(libs.screen.size)
            implementation(compose.material)
            implementation(compose.animation)
            @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
            implementation(compose.components.resources)
            implementation(compose.materialIconsExtended)
            implementation(libs.libres)
            implementation(libs.voyager.navigator)
            implementation(libs.voyager.transitions)
            implementation(libs.voyager.tab.navigator)
            implementation(libs.composeImageLoader)
            implementation(libs.napier)
            implementation(libs.kotlinx.coroutines.core)
            implementation(libs.ktor.core)
            implementation(libs.ktor.client.content.negotiation)
            implementation(libs.composeIcons.fontAwesome)
            implementation(libs.kotlinx.serialization.json)
            implementation(libs.kotlinx.datetime)
            implementation(project.dependencies.platform("io.insert-koin:koin-bom:3.6.0-wasm-alpha2"))
            implementation("io.insert-koin:koin-core")
            implementation("io.insert-koin:koin-compose")
            implementation("io.insert-koin:koin-annotations:1.3.1")
            implementation(libs.ktor.client.logging)
            implementation(libs.io.ktor.ktor.client.serialization)
            implementation(libs.kamel.image)
            implementation(libs.sqlDelight.extension)
            implementation("org.jetbrains.androidx.navigation:navigation-compose:2.7.0-alpha03")
            implementation("org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose:2.8.0-beta02")
            implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.5.0")
        }

        commonTest.dependencies {
            implementation(kotlin("test"))
            @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
            implementation(compose.uiTest)
            implementation(kotlin("test-annotations-common"))
            implementation(libs.kotlinx.coroutines.test)
            implementation(libs.kotest.property)
            implementation(libs.ktor.client.mock)
        }

        androidMain.dependencies {
            implementation(libs.androidx.appcompat)
            implementation(libs.androidx.activityCompose)
            implementation(libs.compose.uitooling)
            implementation(libs.kotlinx.coroutines.android)
            implementation(libs.ktor.client.okhttp)
            implementation(libs.androidx.media3.exoplayer)
            implementation(libs.androidx.media3.exoplayer.dash)
            implementation(libs.androidx.media3.ui)
            implementation(libs.core)
            implementation(libs.core)
            implementation(libs.custom.ui)
            implementation(libs.sqlDelight.driver.android)
            implementation(project.dependencies.platform("io.insert-koin:koin-bom:3.6.0-wasm-alpha2"))
            implementation("io.insert-koin:koin-core")
            implementation("io.insert-koin:koin-android")
            implementation("io.insert-koin:koin-annotations:1.3.1")
            implementation(libs.androidx.glance.app.widget)
            implementation(libs.androidx.glance.material3)
        }

        jvmMain.dependencies {
            implementation(compose.desktop.common)
            implementation(compose.desktop.currentOs)
            implementation(libs.ktor.client.okhttp)
            implementation(libs.vlcj)
            implementation(libs.ffmpeg.platform)
            val fxSuffix = when (osdetector.classifier) {
                "linux-x86_64" -> "linux"
                "linux-aarch_64" -> "linux-aarch64"
                "windows-x86_64" -> "win"
                "osx-x86_64" -> "mac"
                "osx-aarch_64" -> "mac-aarch64"
                else -> throw IllegalStateException("Unknown OS: ${osdetector.classifier}")
            }
            implementation("org.openjfx:javafx-base:19:${fxSuffix}")
            implementation("org.openjfx:javafx-graphics:19:${fxSuffix}")
            implementation("org.openjfx:javafx-controls:19:${fxSuffix}")
            implementation("org.openjfx:javafx-swing:19:${fxSuffix}")
            implementation("org.openjfx:javafx-web:19:${fxSuffix}")
            implementation("org.openjfx:javafx-media:19:${fxSuffix}")
            implementation(libs.sqlDelight.driver.sqlite)
        }

        jsMain.dependencies {
            implementation(compose.html.core)
            implementation(libs.ktor.client.js)
            implementation(libs.sqlDelight.driver.js)
        }

        iosMain.dependencies {
            implementation(libs.ktor.client.darwin)
            implementation(libs.sqlDelight.driver.native)
        }

    }
}

android {
    namespace = "<http://org.company.app|org.company.app>"
    compileSdk = 34

    defaultConfig {
        minSdk = 24
        targetSdk = 34

        applicationId = "org.company.app.androidApp"
        versionCode = 1
        versionName = "1.0.0"
    }
    sourceSets["main"].apply {
        manifest.srcFile("src/androidMain/AndroidManifest.xml")
        res.srcDirs("src/androidMain/resources")
        sourceSets["main"].resources.srcDirs("src/commonMain/resources")
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_19
        targetCompatibility = JavaVersion.VERSION_19
    }
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.14"
    }
}

compose.desktop {
    application {
        mainClass = "MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "org.company.app.desktopApp"
            packageVersion = "1.0.0"
            description = "YouTube Clone Using Kotlin Multiplatform"
            copyright = "© 2024 Muhammad Khubaib Imtiaz. All rights reserved."
            windows {
                iconFile.set(project.file("composeApp/src/commonMain/composeResources/youtube_music.png"))
            }
            macOS {
                iconFile.set(project.file("composeApp/src/commonMain/composeResources/youtube_music.png"))
            }
            linux {
                iconFile.set(project.file("composeApp/src/commonMain/composeResources/youtube_music.png"))
            }
        }
    }
}

compose.experimental {
    web.application {}
}

tasks.getByPath("jvmProcessResources").dependsOn("libresGenerateResources")
tasks.getByPath("jvmSourcesJar").dependsOn("libresGenerateResources")
tasks.getByPath("jsProcessResources").dependsOn("libresGenerateResources")
task("testClasses") {}

buildConfig {

}
sqldelight {
    databases {
        create("YoutubeDatabase") {
            packageName.set("com.youtube.clone.db")
        }
    }
}
p
k
Copy code
+--- org.jetbrains.compose.animation:animation-core:1.6.11
|    |    |    |    +--- org.jetbrains.compose.annotation-internal:annotation:1.6.11 (*)
|    |    |    |    +--- org.jetbrains.compose.collection-internal:collection:1.6.11 (*)
I run the command to check dependencies. I'm using the latest one but still getting error:
You can also check that from repository
p
What you get when you run this task
compileKotlinIosSimulatorArm64
, maybe is my side
If you remember a point time where it worked, you are gonna have to go back there and see what dependency changed or was added between the 2 commits.
k
Basically, I work on windows usually and at the start of this project, I never had a macbook. Now, I have only a iMac. So, I never tested that. But some of my recent projects didn't work too.
I tested those on iMac.
p
Found this link on Google: https://github.com/adrielcafe/voyager/issues/432 Still open in Voyager
You can try cloning voyager and do a build with kotlin
2.0.0
, seems their release was made using
1.9.x
. And maybe there are binary compatibility issues, not sure what could be it TBH.
k
I can see that. But Why unable to get the koin injection inside the iosapp.swift file?
p
That is bc
MainKt.doInitKoin()
is defined inside
ComposeApp.framework
and you haven’t even been able to import
ComposeApp
, bc you havent generated the .framework, the compilation is failing
k
When I try to run iOS App from the Android Studio, I get this error:
Copy code
error: KLIB resolver: Could not find "org.jetbrains.compose.annotation-internal:annotation" in [/Users/zohaibkhan/Downloads/Youtube-Clone-KMP-master 9, /Users/zohaibkhan/.konan/klib, /Users/zohaibkhan/.konan/kotlin-native-prebuilt-macos-x86_64-2.0.0/klib/common, /Users/zohaibkhan/.konan/kotlin-native-prebuilt-macos-x86_64-2.0.0/klib/platform/ios_x64]
This is the same error that you faced also.
p
Yes the same thing.
Copy code
error: KLIB resolver: Could not find "org.jetbrains.compose.annotation-
I just added an issue on github. Let's see, what we get.
Btw, Really Appreciate your time, efforts and help. It means a lot to me. Thank you @Pablichjenkov
🙌 1
p
I believe there was a similar one created before. I posted the link above. Then some folks posted some links to possible libraries. Usually what happens is the library hasn't been released with the same versions you are using.
k
Yeah, this might be the issue.
j
same thing happened to me and i have to check all the dependencies one by one with exact version into a separate project. So, i found that moko resource was incompatible with compose version because it was using old compose version which doesn't support xcode 15 but you're using compose compiler which support xcode 15. So, check which dependencies are using old compose version
1
k
Surely, I'll check that out.
628 Views