Hi, folks! Has anyone solved this yet? `Uncaught Kotlin exception: org.jetbrains.compose.resources.M...
m
Hi, folks! Has anyone solved this yet?
Uncaught Kotlin exception: org.jetbrains.compose.resources.MissingResourceException
I am facing this issue whenever I build the release XcFramework and try to run it. I don't know what's happening, since I am using the following settings(and that shoudn't happen):
Copy code
composeMultiplatform = "1.9.0"
kotlin = "2.2.20"
It was supposed to should work fine after CMP 1.8.2. Also, I can confirm that the resources are present in both simulator and arm64 frameworks, inside the XcFramework. I am running out of options, already read all things related and checked everything.
Update: Also tried to setup compose resources like this:
Copy code
compose.resources {
   publicResClass = true
   packageOfResClass = "com.estudia.res"
   generateResClass = auto
}
But nothing changed. Same error.
i
Which resources do you have in framework ? And how to build framework ?)
Copy code
// My variant :)
val frameworkName = "Shared"
val xcf = XCFramework(frameworkName)
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64()
).forEach {
    it.binaries.framework {
        baseName = frameworkName

        binaryOption("bundleId", "tld.app.${frameworkName}")
        xcf.add(this)
        isStatic = false
    }
}

also:
<https://youtrack.jetbrains.com/projects/CMP/issues/CMP-8232/org.jetbrains.compose.resources.MissingResourceException-Missing-resource-with-path-composeResources>
m
I have pngs, XMLs and strings. I build the framework with: assembleXCFramework. Also, already tried with specific task for Debug or Release XcFramework generation. Same result.
The problem looks to be with strings. But I honestly don't know why.
i
Hmm, I have drawable res (logo.png), and it work good πŸ™‚ For
Res
to appear in the project, however, I had to reset the caches, File > Invalidate Cache and rebuild framework by
./gradlew assembleAppSharedXCFramework
and framework to SPM, and connect it to iOS app
But can't apply new mechanics for resources at all, drawable doesn't contains logo.png πŸ˜‰
Copy code
compose.resources {
    publicResClass = true
    generateResClass = always
}
This doesn't work at all :(
Try to place it here, but not clean project, nor clean chance and rebuild. No one action provide me access to this resources :)
m
I do have access to resources in code. The problem begins after compiling and using it on iOS as a XcFramework. On android, everything works well tho.
i
In my case only
composeResources
work with XCFramework
m
I am using composeResources
i
Which strings in resources do you have, for example Create example with string πŸ™‚
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2025-10-09 Π² 00.17.41.png
Using it like that:
Copy code
text = stringResource(Res.string.hello_message),
And it work
Picture and text from KMP πŸ™‚, conclusion: I create a Framework Dynamic. I saw info about a lot of crashes when use
static
, and resolve it by change it to
dynamic
in gradle:
Copy code
val frameworkName = "Shared"
val xcf = XCFramework(frameworkName)
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64()
).forEach {
    it.binaries.framework {
        baseName = frameworkName

        binaryOption("bundleId", "tld.app.${frameworkName}")
        xcf.add(this)
        isStatic = false
    }
}
in Package.swift
Copy code
import PackageDescription

let package = Package(
    name: "Shared",
    platforms: [
        .iOS(.v16),
    ],
    products: [
        .library(
            name: "Shared",
            targets: ["Shared"]),
    ],
    targets: [
        .binaryTarget(name: "Shared", path: "./Shared.xcframework")
    ]
In your error I assume some problem with strings, you could try to remove it one by one before issue determined, sorry if I can't help you at all :(
m
Let me try compiling it as dynamic. Currently it is static.
Tried more a lot of things. Nothing worked. Do you know if I need to import it with SPM? Because im placing it locally, and referencing in Framework Search Paths.
Also, removed all the strings and then the problem showed with images. So... the problem is with the resources itself, all them.
i
Try to do it with SPM, but I think this not a problem if embed framework itself... I check by embedding a framework directly into project, and it work... show example how to describe in gradle.kt In the libs.versions.toml i have this:
Copy code
composeMultiplatform = "1.9.0"
kotlin = "2.2.20"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }

[plugins]
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
My sourceSet looks like this
My shared folder is:
m
I gave it a last try with SPM (local) and it surprisingly worked. Everything.
For future people: Try it with SPM. Create a folder with a configured Package.swift and your .xcframework. Then, add the dependency(the folder) with SPM, locally.
🦜 1
@iQQator thank you very much! Saved me from days of suffering 🀣
πŸ™Œ 1