Hi, just curious what you guys use for sharing res...
# multiplatform
a
Hi, just curious what you guys use for sharing resources across platforms? Any suggestions? I’ve seen moko-resources. Is this is best one or is there any other options?
👀 2
s
I've been using this, not had any issues but my usecase is only Android and iOS and I'm pretty much exclusively using it for strings. If that's all you need then I can vouch for it
a
How do you manage images, svgs and the likes?
s
I've just been doing that on the individual platforms (mostly because Android uses svgs and iOS uses pdfs)
a
i see thanks for sharing.
d
I've been using SVG's on iOS and Android, but like @Sam, I've been adding these manually to each platform. For other resources, I add a assets folder to my shared library and use gradle to copy assets to each platform (assets folder for Android and an assets bundle for iOS). It's a bit clunky but works.
a
I'm using moko, it gets the job done. I do wish it would automatically regenerate the classes when you edit the resources file, suppose some sort of ide plugin would be required
s
The workflow we've been using in our team which works quite well (and mitigates the regeneration issue) is to have specific subtasks for adding in common resources like this. It means that when a dev creates a branch to start working on UI, the strings are already there from the beginning and generated with the initial sync. (Sorry for the obfuscation, our NDAs are very restricting)
s
Bit of a necro-reply, but I thought I'd throw my approach in the bucket: I also mostly just put things like images in each platform project separately, but for what files I do share, I use Android ["assets"](https://www.geeksforgeeks.org/assets-folder-in-android/) rather than "resources". 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")
        }
    }
}
o
Thanks so much @Sam Saved me lots of trouble 😁
❤️ 1
110 Views