moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

Task ':shared:kspKotlinIosSimulatorArm64' uses this output of task ':shared:generateMRiosSimulatorArm64Main' without declaring an explicit or implicit dependency.

Open kekulta opened this issue 2 years ago • 5 comments
trafficstars

Hi! I'm playing with Compose Multiplatform, ktorfit and moko right now and I have this problem when I'm trying to build for iOS. What could it be?

> Task :shared:generateMRcommonMain `UP-TO-DATE`
> Task :shared:generateMRiosSimulatorArm64Main UP-TO-DATE
> Task :shared:kspKotlinIosSimulatorArm64 FAILED
error: Some problems were found with the configuration of task ':shared:kspKotlinIosSimulatorArm64' (type 'KspTaskNative').

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':shared:kspKotlinIosSimulatorArm64' (type 'KspTaskNative').
  - Gradle detected a problem with the following location: '/Users/kekulta/AndroidStudioProjects/DeepDiveKmm/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.
    
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/Users/kekulta/AndroidStudioProjects/DeepDiveKmm/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.
    
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 853ms
3 actionable tasks: 1 executed, 2 up-to-date

warning: Run script build phase '[CP-User] Build shared' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'shared' from project 'Pods')
** BUILD FAILED **


The following build commands failed:
	PhaseScriptExecution [CP-User]\ Build\ shared /Users/kekulta/AndroidStudioProjects/DeepDiveKmm/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-BEA8885189D408D600647BDC228A6A20.sh (in target 'shared' from project 'Pods')
(1 failure)

Here is also my build.gradle.kts:

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    id("dev.icerock.mobile.multiplatform-resources")
    id("org.jetbrains.compose")
    id("com.google.devtools.ksp") version "1.8.21-1.0.11"
    id("de.jensklingenberg.ktorfit")
    kotlin("plugin.serialization") version "1.8.21"
}


val ktorVersion = "2.3.1"
val ktorfitVersion = "1.4.1"

ksp {
    arg("Ktorfit_Errors", "1")
}

multiplatformResources {
    multiplatformResourcesPackage = "com.example.deepdivekmm"
    iosBaseLocalizationRegion = "en"
}



configure<de.jensklingenberg.ktorfit.gradle.KtorfitGradleConfiguration> {
    version = ktorfitVersion
}

kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        version = "1.0.0"
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            isStatic = true
            export("dev.icerock.moko:resources:0.23.0")
        }
        extraSpecAttributes["resources"] =
            "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                val mokoMvvmVersion = "0.16.1"

                implementation(compose.runtime)
                implementation(compose.foundation)
                implementation(compose.material)
                @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
                implementation(compose.components.resources)

                api("dev.icerock.moko:mvvm-core:$mokoMvvmVersion")
                api("dev.icerock.moko:mvvm-flow:$mokoMvvmVersion")

                api("dev.icerock.moko:mvvm-flow-compose:$mokoMvvmVersion")
                api("dev.icerock.moko:mvvm-compose:$mokoMvvmVersion")

                implementation("io.insert-koin:koin-core:3.3.3")

                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")

                implementation("de.jensklingenberg.ktorfit:ktorfit-lib:$ktorfitVersion")
                implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
                implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")

                api("org.lighthousegames:logging:1.3.0")

                api("dev.icerock.moko:resources:0.23.0")
                api("dev.icerock.moko:resources-compose:0.23.0") // for compose multiplatform
            }
        }
        val androidMain by getting {
            dependencies {
                api("androidx.activity:activity-compose:1.7.2")
                api("androidx.appcompat:appcompat:1.6.1")
                api("androidx.core:core-ktx:1.10.1")

                api("io.insert-koin:koin-android:3.3.3")
            }
        }
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
    }
}


android {
    compileSdk = (findProperty("android.compileSdk") as String).toInt()
    namespace = "com.myapplication.common"

    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    sourceSets["main"].res.srcDirs("src/androidMain/res")
    sourceSets["main"].resources.srcDirs("src/commonMain/resources")

    defaultConfig {
        minSdk = (findProperty("android.minSdk") as String).toInt()
        targetSdk = (findProperty("android.targetSdk") as String).toInt()
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlin {
        jvmToolchain(11)
    }
}

dependencies {
    add("kspCommonMainMetadata", "de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion")
    add("kspAndroid", "de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion")
    add("kspIosX64", "de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion")
    add("kspIosSimulatorArm64", "de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion")
}

also settings.gradle.kts

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
        google()
    }

    plugins {
        val kotlinVersion = extra["kotlin.version"] as String
        val agpVersion = extra["agp.version"] as String
        val composeVersion = extra["compose.version"] as String

        kotlin("jvm").version(kotlinVersion)
        kotlin("multiplatform").version(kotlinVersion)
        kotlin("android").version(kotlinVersion)

        id("com.android.application").version(agpVersion)
        id("com.android.library").version(agpVersion)
        id("org.jetbrains.compose").version(composeVersion)

        id("de.jensklingenberg.ktorfit").version("1.0.0")

        id("dev.icerock.mobile.multiplatform-resources").version("0.23.0")
    }

}

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    }


}


rootProject.name = "DeepDiveKmm"
include(":androidApp")
include(":shared")

My other project is built on top of the template Before I added moko-resources it was working. I don't have any problems with build or run on Android.

kekulta avatar Jun 11 '23 15:06 kekulta

hi. it's gradle 8 strict validations. read https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency

you should add dependencies between gradle task like:

tasks.getByName("kspKotlinIosSimulatorArm64")
    .dependsOn(tasks.getByName("generateMRiosSimulatorArm64Main"))

for all tasks that gradle report in errors

Alex009 avatar Jun 11 '23 16:06 Alex009

Yes, I tried this but could not understand where I should add this line, because when added it In the build.gradle.kts I got this:

Task with name 'kspKotlinIosSimulatorArm64' not found in project ':shared'.


* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.UnknownTaskException: Task with name 'kspKotlinIosSimulatorArm64' not found in project ':shared'.
	at org.gradle.api.internal.tasks.DefaultTaskCollection.createNotFoundException(DefaultTaskCollection.java:102)
	at org.gradle.api.internal.tasks.DefaultTaskCollection.createNotFoundException(DefaultTaskCollection.java:46)
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:333)
	at org.gradle.api.internal.tasks.DefaultTaskCollection.getByName(DefaultTaskCollection.java:46)
	at Build_gradle.<init>(build.gradle.kts:24)
	at Program.execute(Unknown Source)

Where should I look for all this stuff?

kekulta avatar Jun 12 '23 09:06 kekulta

for me it helped adding in build.gradle.kts

tasks.matching { it.name == "kspKotlinIosX64" }.configureEach {
    dependsOn(tasks.getByName("generateMRiosX64Main"))
}
tasks.matching { it.name == "kspKotlinIosArm64" }.configureEach {
    dependsOn(tasks.getByName("generateMRiosArm64Main"))
}

and adding -Pmoko.resources.ARCHS="$ARCHS" \ in the Build Phases task :shared:copyFrameworkResourcesToApp in xcode

peterfromearth avatar Jun 16 '23 13:06 peterfromearth

If your build also has the simulatorArm64 sourceSet you would also have to add this:

tasks.matching { it.name == "kspKotlinIosSimulatorArm64" }.configureEach {
    dependsOn(tasks.getByName("generateMRiosSimulatorArm64Main"))
}

Or maybe even dynamically like this:

tasks.matching { it.name.startsWith("kspKotlin") }.configureEach {
    val sourceSetName = if (name.length == 9) "" else name[9].lowercase() + name.substring(10, name.length)
    tasks.findByName("generateMR$sourceSetName") ?: tasks.findByName("generateMR${sourceSetName}Main")?.let { dependsOn(it) }
}

p-schneider avatar Jun 19 '23 08:06 p-schneider

im having this issue too .. when im adding this

If your build also has the simulatorArm64 sourceSet you would also have to add this:

tasks.matching { it.name == "kspKotlinIosSimulatorArm64" }.configureEach {
    dependsOn(tasks.getByName("generateMRiosSimulatorArm64Main"))
}

Or maybe even dynamically like this:

tasks.matching { it.name.startsWith("kspKotlin") }.configureEach {
    val sourceSetName = if (name.length == 9) "" else name[9].lowercase() + name.substring(10, name.length)
    tasks.findByName("generateMR$sourceSetName") ?: tasks.findByName("generateMR${sourceSetName}Main")?.let { dependsOn(it) }
}

What went wrong: Execution failed for task ':ScanTabletApp:copyResourcesDebugFrameworkIosX64'.

java.io.FileNotFoundException: /Users/ardinata/StudioProjects/ats-android-app/build/ios/Debug-iphonesimulator/FT_ATS.app/FT_ATS:ui_components.bundle/Contents/Resources/Inter-Medium.ttf (No such file or directory)

Deorigami avatar Mar 05 '24 06:03 Deorigami