https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
s

SrSouza

01/28/2023, 8:27 PM
Hi folks, does Compose iOS support Android Drawables? The desktop target support really well. But looking at the implementation it seems that is doing only on Desktop using JVM dependencies for parsing XML. Skiko supports SVG out of the box, but android does not, so if I choose to use SVG, iOS, Desktop and JS would work fine I assume, but Android would not (unless I use a third party library like Android SVG that I don’t currently want to go this path). Do you folks have any toughs on how to approach this ? Multiplatform Vectors
d

Dima Avdeev

01/28/2023, 9:24 PM
For now, iOS target doesn't support drawables resources like in Android. In the future, we want to add this feature in some way. Maybe on Gradle building process, or maybe on runtime.
s

SrSouza

01/28/2023, 10:31 PM
Nice to know, in this case I will get back to svg-to-compose and use for sharing drawables multiplatform
m

Michael Paus

01/29/2023, 2:46 PM
For iOS I used a modified copy of the desktop
androidx.compose.ui.res.SVGPainter
and
androidx.compose.ui.graphics.vector.DrawCache
. I just had to modify the loader slightly to read from a ByteArray. This should work on all platforms which have access to the native SKIA canvas. Basically this includes all platforms except Android. For Android I used AndroidSVG (https://bigbadaboom.github.io/androidsvg/)
s

SrSouza

01/29/2023, 3:01 PM
Nice @Michael Paus, this is a really awesome approach that I was thinking about. I assume that it was out the box the support for SVG in Compose iOS because Skiko supports it, thank you to point out the is currently required to copy the compose files from desktop. My currently goal is only for icon and simple drawables, nothing to fancy. The icon pack that I have here is also used in Android legacy code, so AndroidSVG would require alot of refactoring, so Vector Drawables is better for this case. What I’m planning to do is creating a Gradle plugin that scan
commonMain/resources
for Drawables and uses svg-to-compose to generate the vectors only for iOS or platforms that does not support drawables, but in Android I will keep the drawables for legacy code support.
38 Views