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

neerav

03/15/2024, 11:22 AM
Hello All - I am facing one issue below issue for below mentioned case. Added KMM library Module have compose view with images. Compose version 1.6.1 Kotlin : 1.9.20 Exported framework type :
XCFramework
When i import generated XCFramework to iOS app its getting crash with below error - Image resource missing.
Uncaught Kotlin exception: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: drawable/ic_referral_bubble.png
What else I have tried ? _*As per the 1.6.0 version document
<http://compose.re|compose.re>*_sources
hdpi/ldpi/xhdpi etc drawable folder and image as per resolution but after that it gives error with specific folder.
Uncaught Kotlin exception: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: drawable-xxhdpi/ic_referral_bubble.png
Can anyone please help me how can we resolve this issue. ? Is this because image resources are not getting added in
XCFramework
file ? Thanks
k

Konstantin Tskhovrebov

03/15/2024, 12:32 PM
You cannot export your project with resources as a framework or XCFramework
🤔 1
Because it is Kotlin plugin artefacts. The compose resources can be included into an app only by the Compose gradle plugin
There is no kotlin multiplatform resources. Only compose multiplatform resources
Cc @Timofey Solonin
n

neerav

03/15/2024, 12:41 PM
@Konstantin Tskhovrebov So theres no way to solve KMM library module which have compose UI with Images as a local assets. ?? And export to XCFramework and use that framework in iOS. Same framework working fine if I remove usage of images.
k

Konstantin Tskhovrebov

03/15/2024, 12:45 PM
It is not supported yet. But TBH, a native world does not have a common way to have frameworks with resources. It's a build system responsibility usually. Take a look how it's done in the cocoapods, for example
💔 1
It means you may achieve what you want by framework + resources + special written podspec
n

neerav

03/15/2024, 12:59 PM
is it possible if my library module is without cocoapods ?
k

Konstantin Tskhovrebov

03/15/2024, 1:09 PM
You don't need the cocoapods for your library. Only for distribution frameworks together with resources
u

uli

03/15/2024, 2:19 PM
Your ressources must reside in the main KMM module:
Copy code
Multimodule projects are not supported yet. The JetBrains team is working on adding this functionality in future releases. For now, store all resources in the main application module.
https://blog.jetbrains.com/kotlin/2024/02/compose-multiplatform-1-6-0-release/#common-resources-api
💔 1
b

brandonmcansh

03/15/2024, 9:20 PM
Moko is able to do it but requires using apps to setup moko resource generation too
n

neerav

03/18/2024, 5:07 AM
@brandonmcansh Before
resource
dependecy tried with moko but same like resource error . 😢
b

brandonmcansh

03/18/2024, 5:47 AM
hm too my knowledge and all test setups have it working. see here - https://github.com/BotStacks/compose-example/tree/main
see docs/compose/* for CMP
👀 1
3 Views