Hi :smile: Is there a possibility for keeping reso...
# multiplatform
y
Hi 😄 Is there a possibility for keeping resources(strings, dimens, colors) in the common module and then used in shared Compose compositions that are kept in commonMain?
m
y
Moko resource is platform dependent
m
It seems you are right, despite the fact that it is labeled as “Multiplatform”. Only the API seems to be multi-platform but not the underlying mechanism. So you can’t share the actual resources in some common fashion. Please correct me if I am wrong. What are the relevant platforms for you then? In my case (only Android and Desktop) I just use the good old Java way of storing and retrieving resources. That still works on Android too although it is not very common.
y
I’m also writing application on Android and Desktop. Do you have any samples or resources on how can I achieve the same approach?
m
I just created a folder “resources” under “commonMain” and put all common resources in there. I also have “resources” folders under “desktopMain” and “androidMain” for platform specific resources like, e.g., “META-INF/services/some service declaration”. You can then access these via the usual Java mechanisms, e.g.:
Copy code
SomeClass::class.java.getResource(resourceName)
Note! This works only as long as you restrict yourself to the Java world!