https://kotlinlang.org logo
m

Marcello Galhardo

11/03/2021, 6:33 PM
Hey folks, how are you all handling resources in a multi-platform world? For example, on Android we would normally have a R class with all resources but that would be a problem to share them with Desktop and iOS apps... Any resource (links, good tutorials, GitHub with code...) Is welcomed! Thank you in advance! 🤔
w

wbertan

11/03/2021, 6:40 PM
Here we use https://github.com/icerockdev/moko-resources so far works fine, we share Strings and PNGs from Shared code to Android and iOS - KMM project, not sure if would work with Desktop too 🤔
👍 1
a

ankushg

11/03/2021, 8:00 PM
it does seem to have some support for jvm and macos which is nice, but no js unforutnately I'm looking forward to the feature announced at the premier event where downstream consumers can define `actual`s for unsupported platforms. I think it was something like `external expect`s?
m

Mark Schisler

11/03/2021, 8:24 PM
We used Square’s KotlinPoet to generate our own colors and locales from flat files.
It was pretty simple to do and less complicated than moko-resources
There’s not a whole lot of value in sharing images as they are different files (PDF vs SVG), so that’s pretty irrelevant.
👍 1
w

wbertan

11/03/2021, 8:39 PM
Agreed, we don’t share when it is PDF/SVG 😞 Currently approach is to have an
enum
“representing” the icon and the view resolves it to the native icon. BUT we also use some PNGs, which moko-resource is fine to share. Also we share directly as
String
, our shared classes resolve (via some extensions) from the
StringDesc
to
String
.
6 Views