Can we have resources in klib?
c
Can we have resources in klib?
๐Ÿ‘ 1
c
There is the same problem on KJS. Until this is implemented, I created a Gradle plugin to do this: https://gitlab.com/opensavvy/automation/kotlin-js-resources Currently, it only supports KJS, because I don't use Native. However, if you submit an example project, I could add support for Native as well. It works by creating a new multiplatform artifact (so, not in the klib directly) that is automatically published alongside the project to MavenCentral/MavenLocal etc.
m
@CLOVIS how would you embed & access the resources in the final binary? (
a.out
)
c
Ah, the binary itself I don't know. Since the OP mentioned klib files, I assumed this was as part of a library.
m
Gotcha ๐Ÿ‘
Iโ€™m interested in APIs to use those at runtime as well. My current quick & dirty solution for moderate size resources is to just encode them to strings which is very easy to do in a KMP way but is suboptimal (goes through decoding, cannot stream the resource, etc...)
c
To clarify: my plugin allows to retrieve resources from other subprojects/dependencies as if they were part of the current project. After that, everything works exactly the same way as if you declared the resources in the project you're working onโ€”so if K/N can't do much with that, my plugin won't help.
๐Ÿ‘ 1
That's probably very native-platform-dependent ๐Ÿ˜•
c
@CLOVIS I want something that will end up in the final app bundle esp on iOS
Same way compose resources does it.