Skip to content

No access to resources in multi-module project #824

@aleksey-ho

Description

@aleksey-ho

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions