Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved reference 'SharedRes' in moko-resources v0.24.5 [2025] #805

Open
Dardev12 opened this issue Feb 12, 2025 · 0 comments
Open

Unresolved reference 'SharedRes' in moko-resources v0.24.5 [2025] #805

Dardev12 opened this issue Feb 12, 2025 · 0 comments

Comments

@Dardev12
Copy link

When trying to use SharedRes in the project, an "Unresolved reference 'SharedRes'" error occurs. This issue seems to be related to the configuration of moko-resources in the project.

Environment

  • Moko Resources Version: 0.24.5
  • Moko Graphics Version: 0.9.0
  • Gradle Version: 8.10.2
  • Android Compile SDK: 34
  • iOS Deployment Target: 16.0

Related Configuration Files

libs.moko.toml

[versions]
moko = "0.24.5"
moko-graphics = "0.9.0"

[libraries]
mokoLibResources = { module = "dev.icerock.moko:resources", version.ref = "moko" }
mokoResourcesGenerator = { module = "dev.icerock.moko:resources-generator", version.ref = "moko" }
mokoGraphics = { module = "dev.icerock.moko:graphics", version.ref = "moko-graphics" }
mokoCompose = { module = "dev.icerock.moko:resources-compose", version.ref = "moko" }

[plugins]
mokoResources = { id = "dev.icerock.mobile.multiplatform-resources" }

build.gradle.kts (root)

plugins {
    alias(libs.plugins.kotlinMultiplatform).apply(false)
    alias(libs.plugins.kotlinCocoapods).apply(false)
    alias(libs.plugins.androidLibrary).apply(false)
}

buildscript {
    dependencies {
        classpath(moko.mokoResourcesGenerator)
    }
}

build.gradle.kts (shared)

import dev.icerock.gradle.MRVisibility

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.kotlinCocoapods)
    alias(libs.plugins.androidLibrary)
    alias(google.plugins.googleServices)
    alias(other.plugins.ktlint)
    alias(moko.plugins.mokoResources)
    //alias(sqldelight.plugins.initiliazer)
}

kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    task("testClasses")
    jvmToolchain(21)
    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
            linkerOpts.add("-lsqlite3")
        }
    }

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "16.0"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            export(moko.mokoLibResources)
            export(moko.mokoGraphics)
            isStatic = true
        }
        extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
        extraSpecAttributes["exclude_files"] = "['src/commonMain/resources/MR/**']"
    }
    
    sourceSets {
        val commonMain by getting {
            dependencies {
                api(moko.mokoLibResources)
                api(moko.mokoCompose)
                implementation("dev.icerock.moko:parcelize:0.8.0")
                //implementation(sqldelight.sqlCommon)

                implementation(ktor.ktorCore)
                implementation(ktor.ktorCio)

                implementation(coroutines.coroutineCoreKMM)

                implementation(kotlinx.kotlinxSerialization)
                implementation(kotlinx.kotlinxDatetime)

                implementation(other.napier)
                implementation(other.slf4j)

                api(koin.koinCore)

                implementation(firebase.firebaseAuthentication)
                implementation(firebase.firebaseFirestore)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(libs.kotlin.test)
            }
        }
        val androidMain by getting {
            kotlin.srcDir("build/generated/moko/androidMain/src")
            dependencies {
                //implementation(sqldelight.sqlAndroid)
                implementation(ktor.ktorAndroid)
                //api(moko.mokoCompose)
            }
        }
        androidNativeTest.dependencies {
            implementation(test.junit)
            implementation(test.mockk)

            //implementation(sqldelight.sqlDriver)
            //implementation(sqldelight.sqlJKvm)
        }
        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 {
                //implementation(sqldelight.sqlIos)
                implementation(ktor.ktorIos)
                implementation(other.touchlabStately)
            }
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
}

/*sqldelight {
    databases {
        create("idea") {
            packageName.set("com.kmp.idea.database")
            srcDirs.setFrom("src/commonMain/sqldelight")
        }
    }
    linkSqlite = true
}*/

android {
    namespace = "com.kmp.idea"
    compileSdk = 34
    defaultConfig {
        minSdk = 24
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_21
        targetCompatibility = JavaVersion.VERSION_21
    }
}

multiplatformResources {
    resourcesPackage.set("com.kmp.idea")
    resourcesClassName.set("SharedRes")
    resourcesVisibility.set(MRVisibility.Internal)
    iosBaseLocalizationRegion.set("en")
    iosMinimalDeploymentTarget.set("16.0")
}

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
    verbose.set(true)
    ignoreFailures.set(false)
    //disabledRules.set(setOf("final-newline", "no-wildcard-imports","function-naming"))
    reporters {
        reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN)
        reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE)
        reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.SARIF)

    }
}

Expected Outcome

  • SharedRes should be correctly recognized and used in the project without unresolved reference errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant