KSP ':shared:kspKotlinIosSimulatorArm64' error
Ktorfit version
1.11.1
What happened and how can we reproduce this issue?
Hello. I think this might be some kind of question. I keep getting this error for building the iOS app. The android is OK:
Some problems were found with the configuration of task ':shared:kspKotlinIosSimulatorArm64' (type 'KspTaskNative').
- Gradle detected a problem with the following location: '/Users/shadmanadman/AndroidStudioProjects/MarketMLM/shared/build/generated/moko/iosSimulatorArm64Main/src'.
Reason: Task ':shared:kspKotlinIosSimulatorArm64' uses this output of task ':shared:generateMRiosSimulatorArm64Main' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':shared:generateMRiosSimulatorArm64Main' as an input of ':shared:kspKotlinIosSimulatorArm64'.
2. Declare an explicit dependency on ':shared:generateMRiosSimulatorArm64Main' from ':shared:kspKotlinIosSimulatorArm64' using Task#dependsOn.
3. Declare an explicit dependency on ':shared:generateMRiosSimulatorArm64Main' from ':shared:kspKotlinIosSimulatorArm64' using Task#mustRunAfter.
For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
- Gradle detected a problem with the following location: '/Users/shadmanadman/AndroidStudioProjects/MarketMLM/shared/build/generated/moko/commonMain/src'.
Reason: Task ':shared:kspKotlinIosSimulatorArm64' uses this output of task ':shared:generateMRcommonMain' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':shared:generateMRcommonMain' as an input of ':shared:kspKotlinIosSimulatorArm64'.
2. Declare an explicit dependency on ':shared:generateMRcommonMain' from ':shared:kspKotlinIosSimulatorArm64' using Task#dependsOn.
3. Declare an explicit dependency on ':shared:generateMRcommonMain' from ':shared:kspKotlinIosSimulatorArm64' using Task#mustRunAfter.
You can see my Gradle file here. I added the needed ksp dependencies:
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.realm)
alias(libs.plugins.compose)
alias(libs.plugins.kotlinSerialization)
alias(libs.plugins.ktorfit)
alias(libs.plugins.google.devtools)
id("dev.icerock.mobile.multiplatform-resources")
}
kotlin {
applyDefaultHierarchyTemplate()
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
export(libs.moko.resources.compose)
export(libs.moko.graphics)
}
}
sourceSets {
val androidMain by getting {
dependsOn(commonMain.get())
dependencies {
// Ktor okHttp
implementation(libs.ktor.client.okhttp)
implementation(libs.ktor.client.android)
}
}
val commonMain by getting {
dependencies {
// Compose
implementation(compose.runtime)
implementation(compose.animation)
implementation(libs.jetbrains.foundation)
implementation(compose.material3)
implementation(libs.jetbrains.ui)
// Decompose
api(libs.decompose)
api(libs.decompose.extensions)
api(libs.decompose.essenty)
// Realm
implementation(libs.realm.base)
implementation(libs.realm.sync)
// KotlinX
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.json)
// Ktor
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.serialization)
implementation(libs.ktor.client.json)
implementation(libs.ktor.client.negotiation)
implementation(libs.ktor.client.logging)
// Ktorfit
implementation(libs.ktorfit.lib)
// Kamel
implementation(libs.kamel.image)
// Moko
api(libs.moko.resources.compose)
// Gson
implementation(libs.gson)
// Koin
implementation(libs.koin.core)
implementation(libs.koin.test)
// Insetsx for controlling status bar and navigation bar
implementation(libs.insetsx)
}
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by getting {
dependencies {
// Ktor Darwin
implementation(libs.ktor.client.darwin)
}
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
}
}
dependencies {
add("kspCommonMainMetadata", libs.ktorfit.ksp)
add("kspAndroid", libs.ktorfit.ksp)
add("kspIosX64", libs.ktorfit.ksp)
add("kspIosArm64",libs.ktorfit.ksp)
add("kspIosSimulatorArm64",libs.ktorfit.ksp)
add("kspIosSimulatorArm64",libs.ktorfit.ksp)
}
//tasks.named(":shared:kspKotlinIosSimulatorArm64") {
// dependsOn(":shared:generateMRiosSimulatorArm64Main")
//}
android {
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
namespace = "com.marketmlm.modern"
compileSdk = 34
defaultConfig {
minSdk = 26
}
}
multiplatformResources {
multiplatformResourcesPackage = "com.marketmlm.modern"
multiplatformResourcesClassName = "SharedRes"
disableStaticFrameworkWarning = true
}
task("testClasses").doLast {
println("This is a dummy testClasses task")
}
What did you expect to happen?
After adding the explicit dependencies to the requested task, the Gradle will not sync and throws an error:
tasks.named("shared:kspKotlinIosSimulatorArm64") {
dependsOn(":shared:generateMRcommonMain")
}
the error is:
Task with name ':shared:kspKotlinIosSimulatorArm64' not found in project ':shared'
Is there anything else we need to know about?
No response
So I find a workaround for this issue. You put the following tasks in your Gradle file and you should be OK. This will declare the explicit dependencies for all iOS platforms:
project.afterEvaluate {
tasks.named("kspKotlinIosSimulatorArm64") {
dependsOn("generateMRiosSimulatorArm64Main")
}
tasks.named("kspKotlinIosX64") {
dependsOn("generateMRiosX64Main")
}
tasks.named("kspKotlinIosArm64") {
dependsOn("generateMRiosArm64Main")
}
}
Thank you for your bug report and the workaround!