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

MR has no actual declaration in test for Native

Open marcorighini opened this issue 2 years ago • 9 comments

When running native tests e.g. iosX64Test we are getting the error Expected object 'MR' has no actual declaration in module <com....:core-data_test> for Native where core-data is the name of the module containing common tests

marcorighini avatar Sep 15 '22 11:09 marcorighini

I encountered a similar issue Expected object 'MR' has no actual declaration in module <shared_debug> for JVM

lekeCoder avatar Aug 12 '23 21:08 lekeCoder

Same for me

Expected object 'MR' has no actual declaration in module <module_name:site> for JS

EchoEllet avatar Sep 10 '23 22:09 EchoEllet

As mentioned in other issues with the same problem add dependsOn(commonMain) to androidMain in the build.gradle file.

val androidMain by getting {
            dependsOn(commonMain)
            dependencies {
                 ...
            }
}

SimonJackler avatar Sep 13 '23 15:09 SimonJackler

As mentioned in other issues with the same problem add dependsOn(commonMain) to androidMain in the build.gradle file.

val androidMain by getting {
            dependsOn(commonMain)
            dependencies {
                 ...
            }
}

How would this be in the build.gradle.kts version?

JakkeJ avatar Oct 01 '23 11:10 JakkeJ

@SimonJackler adding

val androidMain by getting {
            dependsOn(commonMain)
            dependencies {
                 ...
            }
}

cuases other weird issues!

it cannot find actual vals for iosMain and forces me to add actual for all iosX64, iosArm64, iosSimulatorArm64

any idea?

Adding the following resolves the issue but it looks ugly!

    val androidMain by getting {
      dependsOn(commonMain.get())
    }
    val iosMain by getting {
      dependsOn(commonMain.get())
    }
    val iosArm64Main by getting {
      dependsOn(iosMain)
    }
    val iosSimulatorArm64Main by getting {
      dependsOn(iosMain)
    }
    val iosX64Main by getting {
      dependsOn(iosMain)
    }

Thanks

bidadh avatar Nov 11 '23 10:11 bidadh

@bidadh Thats the way it works for me too. Ugly or not, it works :)

    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)
        dependencies {
            ...
        }
    }

SimonJackler avatar Nov 11 '23 15:11 SimonJackler

@SimonJackler yes. we used to do this with the older versions of compose multiplatform plugin but with the latest version it's much cleaner in terms of the gradle modules / builds

this is sort of one step back! haha.

but as you said, it works and it's good

bidadh avatar Nov 12 '23 00:11 bidadh

Adding targetHierarchy.default() in the kotlin {} block solved the issue for me. Reference

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
    targetHierarchy.default()
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    iosX64()
    iosArm64()
    iosSimulatorArm64()
   // .......
}

rdsarna avatar Nov 24 '23 10:11 rdsarna

Adding targetHierarchy.default() in the kotlin {} block solved the issue for me.

That call is no deprecated and replaced with applyDefaultHierarchyTemplate(), but it has no effect on the issue for me

dalewking avatar Nov 25 '23 01:11 dalewking