icerockdev / moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.11k stars 123 forks source link

Value of type 'ResourcesStringResource' has no member 'desc' #338

Closed matteinn closed 2 years ago

matteinn commented 2 years ago

Hi there! I'm trying to integrate the library in a KMM project and I'm facing some issues with the usage on the iOS app (integrated via "iOS framework distribution": "Regular framework").

Here's the error: Value of type 'ResourcesStringResource' has no member 'desc'

Screenshot 2022-05-07 at 03 06 34

I'm attaching the empty project generated by AS with the only addition of moko-resources that demonstrates the issue: ABC.zip

Are there any other steps needed?

If I also apply what's mentioned in https://github.com/icerockdev/moko-resources#static-kotlin-frameworks-support (which I believe it's necessary) then I get another error during that build phase: Task 'copyFrameworkResourcesToApp' not found in project ':shared'.

Hence I suspect that the readme might be missing some crucial information.

Thanks in advance

Alex009 commented 2 years ago

to use kotlin methods from swift you should add library to export. https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#export-dependencies-to-binaries

sample: https://github.com/icerockdev/moko-resources/blob/master/sample/mpp-hierarhical/build.gradle.kts#L49

matteinn commented 2 years ago

Thanks, that indeed fixed the issue!

applepeopletsai commented 2 years ago

Hi, @matteinn I face the same issue And I can't fix it by @Alex009 's answer Could you show me how did you fix it? Thx.

matteinn commented 2 years ago

@applepeopletsai in the end I was only missing the export statement shown below. Hope it solves your error too

kotlin {
    ....
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            export("dev.icerock.moko:resources:$mokoResourcesVersion")
        }
    }
    ...
}
applepeopletsai commented 2 years ago

WOW!! It's working Thank you very much You save my day :)