Hi, can I somehow use Compose Multiplatform Resour...
# multiplatform
j
Hi, can I somehow use Compose Multiplatform Resources in a KMP only library? I am trying to migrate a multi-module project to CMP/KMP. I migrated modules which had Compose to CMP and thus it's working fine with Compose Multiplatform Resources. I have plenty of other modules which do not require Compose, but still contain some e.g. string resources or have models which take string resource as a parameter, I'd like to convert those to a pure KMP library and use Compose Multiplatform Resources too, is this even possible for a KMP library?
t
@Jokubas Trinkunas Hello! There are shared resources for KMP/CMP, but they don't operate like the old ways. You need to properly implement the shared resources library as well as tell your platforms via Gradle what to build for folder structure and look for. Thankfully it's fairly documented and straightforward, but it still can be a chore to do initially. Start with this from Jetbrains https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-multiplatform-resources.html and if you're still struggling after, lookup a youtube video from philip lackner called "How to Share Resources in KMM (Strings, Images, etc.)" from about 2 years ago. Good luck!
j
Thank you for the reply, just to confirm, it's ok to use Compose Multiplatform Resources for a KMP only lib? I want to avoid mixing Moko and Compose Multiplatform Resources.
t
I would avoid mixing resource systems like you said (I could even be wrong there as I don't use Moko), but for the Compose Multiplatform Resources for a KMP only lib, I think it's the proper way to go as alternatives would be needing to implement native resources and handling things that way will be more tedious and further implementations. It's much smoother and straightforward when you can keep things shared.
👍 1