https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

AmrJyniat

03/20/2023, 12:48 PM
Is there a way to share
.xml
files between Android&IOS?
r

rudolf.hladik

03/20/2023, 1:05 PM
i've just used this solution for json files. xml will be the same
e

Evegenii Khokhlov

03/20/2023, 1:35 PM
could you tell more about use-case?
a

AmrJyniat

03/20/2023, 1:37 PM
I have a
shape
xml file, can I share it with IOS?
e

Evegenii Khokhlov

03/20/2023, 1:42 PM
and how you want to use it in iOS?
a

Ahmad Hassan

03/20/2023, 5:29 PM
I also have the same question. For example, I want to achieve localization. What will be the approach?
e

Evegenii Khokhlov

03/20/2023, 5:33 PM
@Ahmad Hassan for localization I would suggest looking at https://github.com/icerockdev/moko-resources But I would prefer using some localization platform it is pretty easy to keep keys there and generate translation files for both platforms
s

Sam

03/21/2023, 12:42 AM
I personally wasn't able to get the
resources
approach to work without errors, but I found what to me is a simpler approach that also hits up against fewer naming convention issues. I also mostly just put things like images in each platform project separately, but for what files I do share, I use Android "assets" rather than "resources". I use this to share some JSON files. Obviously this won't work for anything where e.g. Android requires an XML resource, but for files you just read at runtime, it works great. I have a folder
shared/src/commonMain/assets
and then the following config:
Copy code
kotlin {
    cocoapods {
        extraSpecAttributes.apply {
            this["resources"] = "'src/commonMain/assets/**/*'"
        }
    }
}

android {
    sourceSets {
        named("main") {
            assets.srcDir("src/commonMain/assets")
        }
    }
}
k

Konstantin Tskhovrebov

03/21/2023, 9:05 AM
I propose to try https://github.com/Skeptick/libres for common resources
15 Views