https://kotlinlang.org logo
k

Konstantin Petrukhnov

09/17/2019, 6:48 AM
What is suggested way to distribute resource files in MPP library? E.g. iOS app <- fwbundle <- lib-a <- lib-b; androidApp <- lib-a <- lib-b. lib-b have file "mytext.txt" that need to be accessed from lib-a class. lib-a class is used from iOS app. In which folder mytext.txt should be created (src/commonMain/resources?)? How to ensure, that it is exported in fwbundle.framework (so it is available to code from lib-a and to code from iOS app itself)?
g

gildor

09/17/2019, 7:29 AM
There is no support of MPP resources out of the box, as I know
Only JVM is supported
But as I remember, I saw some third party Gradle plugin that adds resources support for MPP
a

alex009

09/17/2019, 8:09 AM
for ios you can move files to framework by custom gradle task. sample in our gradle plugin for resources - https://github.com/icerockdev/moko-resources/blob/b061ccb90c5ffd1102a173bb4d99e4e4c7766605/gradle-plugin/src/main/kotlin/dev/icerock/gradle/generator/IosMRGenerator.kt#L58 our plugin allow use localization resources at mobile platforms - https://github.com/icerockdev/moko-resources
g

gildor

09/17/2019, 8:13 AM
For JS it’s also possible using things like WebPack. but it’s all custom configs, nothing out of the box
k

Konstantin Petrukhnov

09/17/2019, 8:45 AM
@alex009 lib-b. lib-a, fwbundle - are separate projects. How do i bring resource from lib-b to fwbundle? When I build and publish lib-b.klib, it don't have any resources inside (but jar do have)
a

alex009

09/17/2019, 8:47 AM
klib can't have resources. you can only write gradle task which will be execute after linkFramework task and this task copy files from your directory with resources to framework directory
k

Konstantin Petrukhnov

09/17/2019, 8:52 AM
hm.. this page (at the end) refer to resources: https://kotlinlang.org/docs/reference/native/libraries.html
a

alex009

09/17/2019, 8:54 AM
as i know at now resources not passed to framework or klibs. @svyatoslav.scherbina can you help us?
k

Konstantin Petrukhnov

09/17/2019, 12:08 PM
I wonder if I could extract all resources from jars of libs marked for transitiveExport.
🤔 1
And then pack them in framework.
s

svyatoslav.scherbina

09/18/2019, 8:17 AM
hm.. this page (at the end) refer to resources: https://kotlinlang.org/docs/reference/native/libraries.html
Well, it actually does:
- resources/
- General resources such as images. (Not used yet).
I guess this documentation describe current state clearly enough.
as i know at now resources not passed to framework or klibs.
Correct.
👍 1
k

Konstantin Petrukhnov

09/18/2019, 9:01 AM
@svyatoslav.scherbina is there any issue number about exporting resources in klib, so I could follow it? There are ~5 issues somehow related to it in YT. Maybe this one? https://youtrack.jetbrains.com/issue/KT-29311
s

svyatoslav.scherbina

09/18/2019, 9:23 AM
Feel free to follow any issue that is related to your particular case.