Trying to use the new resource handling in Compose...
# multiplatform
t
Trying to use the new resource handling in Compose MP. Two questions: • Do we expect it to support .svg files directly in drawable folder? Or do I need to use the Android import to generate an Android XML format? • I have a custom sourceset composableMain in order to manage building watchOS (no Compose support) and all other targets. When I run the gradle shared:generateComposeResClass it appears to run (gives no errors) but there is no resultant Res file. Is this likely because of the custom sourceset? I tried putting the composeResources in the commonMain, but it still does nothing. Anybody have any clues on how to make it work? I am using compose mp 1.6.0-rc01.
All answers are here
t
I was following that page, and the answers are not exactly there: • "or a
VectorPainter
for XML vector drawable formats like
.xml
." The 'like' implies that there might be other formats accepted, but they are not specified. Hence the question here. • All the examples show using commonMain, but nowhere does it say that is required. Hence the second question - do we expect it to work in other sourceSets?
k
@Danil Pavlov cc
👀 1
Only android XML is supported. Accessors are being generated only for commonMain at the moment. If you would like to have these features, create GitHub issues please
t
Okay, thank you.
m
I’m still struggling with fonts, but i would assume since android itself doesn’t support svg, you can’t use it in multiplatform
t
Right, I got it working by imported in AS to the app level, and copying the .xml to the composeResources which I also moved to commonMain. Works great on Android, but a build error on iOS. So for now I will stick with Material Icons.
correction: fixed the iOS issue: the import for the Res was broken. Fixed and now it appears to working okay.
m
Hey, I'm also attempting to use an XML vector in my iOS project but it keeps crashing whenever the icon tries to render. @tylerwilson Any ideas from how you got yours to work?
I keep getting
Uncaught Kotlin exception: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: drawable/insta_icon.xml
t
i suspect it is not being copied to the resultant framework for some reason. how are you integrating the shared code with your iOS app? cocoapods or Xcode Run Script or XCFramework? I am using the XCode Run Script which calls the gradle :embedAndSignAppleFrameworkForXcode and it is working well (once I update the import to match the generated package). Also confirm that it has the resources in build/generated/compose/resourceGenerator/kotlin.
Also, I undid using the resources for now and just use a Material Icon until this issue is fixed: https://github.com/JetBrains/compose-multiplatform/issues/4320
m
Thanks a lot. It turns out the issue was using it alongside Moko resources. It seems to have a conflict with that particular library. I was planning on migrating to compose resources gradually, but it seems like that'll have to be done in one fell swoop
👍 1
549 Views