Is there a way to share `.xml` files between Andro...
# multiplatform
a
Is there a way to share
.xml
files between Android&IOS?
r
i've just used this solution for json files. xml will be the same
e
could you tell more about use-case?
a
I have a
shape
xml file, can I share it with IOS?
e
and how you want to use it in iOS?
a
I also have the same question. For example, I want to achieve localization. What will be the approach?
e
@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
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
I propose to try https://github.com/Skeptick/libres for common resources