Hello all, I have this error while trying out compose multiplatform. `error: Cannot query the value ...
e
Hello all, I have this error while trying out compose multiplatform.
error: Cannot query the value of this provider because it has no value available. * What went wrong:
Execution failed for task ':composeApp:syncComposeResourcesForIos'.
> Cannot query the value of this provider because it has no value available.
And in XCode, I have this error:
/KMP/iosApp/iosApp/ContentView.swift:3:8 No such module 'ComposeApp'
. I have tried to apply many solution i foound online which does not work. I tried to use
./gradlew composeApp:syncComposeResourcesForIos
I got:
> Task :composeApp:syncComposeResourcesForIos FAILED. * What went wrong:
Execution failed for task ':composeApp:syncComposeResourcesForIos'.
> Error while evaluating property 'xcodeTargetArchs' of task ':composeApp:syncComposeResourcesForIos'.
> Could not infer iOS target architectures. Make sure to build via XCode (directly or via Kotlin Multiplatform Mobile plugin for Android Studio)
. What am I doing wrong? How can I solve this issue?
j
Might help to share what versions of Kotlin & Compose you're using, and how your build.gradle.kts looks 💡
c
The error would indicate that the package you are importing in the iOS project does not match what it's defined as in the Kotlin gradle script. Did you change the
baseName
of the iOS binary (in the shared module build.gradle file) and perhaps not make the same change in the iOS project? (Namely the
ContentView.swift
file where the import is declared
n
@Jacob Ras kotlin 2.2.0 and compose 1.9.0. I created a new project and tried running iOS and got that error.
e
Thanks for the response. I had a little problem with my PC.
Here is my gradle file in composeApp/build.gradle.kt:
Copy code
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.composeMultiplatform)
    alias(libs.plugins.composeCompiler)
}

kotlin {
    androidTarget {
        compilerOptions {
            jvmTarget.set(JvmTarget.JVM_11)
        }
    }
    
    listOf(
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
        }
    }
    
    sourceSets {
        androidMain.dependencies {
            implementation(compose.preview)
            implementation(libs.androidx.activity.compose)
        }
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.androidx.lifecycle.viewmodelCompose)
            implementation(libs.androidx.lifecycle.runtimeCompose)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
    }
}

android {
    namespace = "com.ezadetoro.myapplication"
    compileSdk = libs.versions.android.compileSdk.get().toInt()

    defaultConfig {
        applicationId = "com.ezadetoro.myapplication"
        minSdk = libs.versions.android.minSdk.get().toInt()
        targetSdk = libs.versions.android.targetSdk.get().toInt()
        versionCode = 1
        versionName = "1.0"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
}

dependencies {
    debugImplementation(compose.uiTooling)
}
Kotlin version: 2.2.20
project structure:
@Jacob Ras @Ciaran Sloan Please guys check.
c
It's hard to see from what's shared. Can you share a reproducible sample project?
e
Here is link to sample project: https://github.com/adetorodev/kmp-application
t
@Ezekiel Adetoro no need to spam the channel
239 Views