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

No access to resources in multi-module project

Open aleksey-ho opened this issue 5 months ago • 1 comments
trafficstars

I added the necessary integration to the project:

alias(libs.plugins.multiplatform.resources)
api(libs.moko.resources) // in commonMain
framework {
    baseName = "ui"
    isStatic = true
    ...
}
multiplatformResources {
    multiplatformResourcesPackage = "app.myapp.core.ui"
}

I found copyFrameworkResourcesToApp in the warning logs and added

"$SRCROOT/../gradlew" -p "$SRCROOT/../" :core:ui:copyFrameworkResourcesToApp \
-Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" \
-Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH" \ 
-Pkotlin.native.cocoapods.platform="$PLATFORM_NAME" \ 
-Pkotlin.native.cocoapods.archs="$ARCHS" \ 
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"

I see that the bundle is copied into the application assembly, but under the name MyApp.core/ui.bundle And I can even access the resource like this:

if let bundleUrl = Bundle.main.url(forResource: "MyApp.core:ui", withExtension: "bundle"),
    let resourcesBundle = Bundle(url: bundleUrl) {
    let localizedString = NSLocalizedString("profile_title", bundle: resourcesBundle, comment: "")
}

But I don't have proper access to the resource: print(MR.strings.profile_title.desc().localized()) // no access to MR

Please help, did I misconfigure it?

aleksey-ho avatar Jun 17 '25 17:06 aleksey-ho