Thread
#multiplatform
    k

    Konstantin Petrukhnov

    3 years ago
    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)?
    gildor

    gildor

    3 years ago
    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
    alex009

    alex009

    3 years ago
    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
    gildor

    gildor

    3 years ago
    For JS it’s also possible using things like WebPack. but it’s all custom configs, nothing out of the box
    k

    Konstantin Petrukhnov

    3 years ago
    @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)
    alex009

    alex009

    3 years ago
    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

    3 years ago
    hm.. this page (at the end) refer to resources: https://kotlinlang.org/docs/reference/native/libraries.html
    alex009

    alex009

    3 years ago
    as i know at now resources not passed to framework or klibs. @svyatoslav.scherbina can you help us?
    k

    Konstantin Petrukhnov

    3 years ago
    I wonder if I could extract all resources from jars of libs marked for transitiveExport.
    And then pack them in framework.
    s

    svyatoslav.scherbina

    3 years ago
    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.
    k

    Konstantin Petrukhnov

    3 years ago
    @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

    3 years ago
    Feel free to follow any issue that is related to your particular case.