Anyone has a good tutorial for shared resources (d...
# multiplatform
s
Anyone has a good tutorial for shared resources (drawable, strings, colors) ? Moko isn't working with kotlin 1.9+. I tried to follow https://www.netguru.com/blog/kotlin-multiplatform-resources but i don't have a resourceGeneratorTask.
j
What issue you are facing? As i am also using moko its working fine as excepted.
โœ… 1
s
With which kotlin version ? I can't get the MR object generated
j
I am using
kotlin 1.9.20
๐Ÿค” 1
s
And it worked immediately following the installation tuto from the readme ?
j
No. But you need to add
dependsOn(commonMain)
inside the android block in shared
build.gradle
file
s
Yeah i tried that, spent my afternoon yesterday trying all the fixes i could find but nothing worked ๐Ÿฅฒ
๐Ÿ˜Ÿ 1
Turns out I just might not get the idea out of it... MR object exist but only outside commonMain packages
So I just need to changed my shared data class and not expect an ImageResources in it.
@Jhaman das Would it be possible to see your build.gradle ?
r
works for me on kotlin 1.9.* commonMain dependencies
Copy code
api("dev.icerock.moko:resources:0.23.0")
api("dev.icerock.moko:resources-compose:0.23.0")
iOS targets
Copy code
framework {
    baseName = "shared"
    isStatic = true
    export("dev.icerock.moko:resources:0.23.0")
}
had to also do that
Copy code
val androidMain by getting {
     sourceSets {
         getByName("androidMain").kotlin.srcDirs("build/generated/moko/androidMain/src")
}
and
Copy code
val iosX64Main by getting {
    resources.srcDirs("build/generated/moko/iosX64Main/src")
}
val iosArm64Main by getting {
    resources.srcDirs("build/generated/moko/iosArm64Main/src")
}
val iosSimulatorArm64Main by getting {
    resources.srcDirs("build/generated/moko/iosSimulatorArm64Main/src")
}
had to also do that
this part found in one of the issues in their github as a temp fix until they fix their code
s
And you can access MR in the commonMain module ? I still have no build for the resources there, just the expect MR
r
yes
no build for the resources there
even after you rebuild the app?
s
Yep, even after rebuilding, still no resources in commonMain, just the expect MR object.
Quite frustrating
r
are you sure youโ€™re using the latest version?
had similar issues in the past
s
mokoResources = "0.23.0"
r
hmm
can you show your โ€
Copy code
multiplatformResources
โ€ block?
s
I only left the mandatory part :
Copy code
multiplatformResourcesPackage = "dev.nar.resources" // required
โœ… 1
Ah! it actually work, just the reference can't be find by the autocomplete
๐Ÿ˜… 1
Spent 2 days battling with it, because of that ๐Ÿ˜ฎโ€๐Ÿ’จ
r
ah shit ๐Ÿ˜„ good to know you fixed it
s
Yep, thanks for the help, I'll finally be able to start my project... until the next problem ๐Ÿ˜„
๐Ÿ™Œ 1
r
trust me, you will face many.. ๐Ÿ˜„
but feel free to ask
s
Oh I'm sure I'll, even with a relatively easy to do app ^^ Won't hesitate to ask thanks
โœ… 1
๐Ÿ‘€ 1