https://kotlinlang.org logo
Title
s

Sergio C.

04/25/2023, 7:11 PM
Why does this crash on iOS?
Image(painter = painterResource("image.jpg"), contentDescription = null)
It works fine on Android. Loading xml vectors also work fine on both platforms.
a

Alexander Maryanovsky

04/25/2023, 7:15 PM
Is there a stack trace of the crash?
s

Sergio C.

04/25/2023, 7:16 PM
from Android studio I don’t see a stack trace
I’ll try xcode
got it. Uncaught Kotlin exception: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: image.jpg
somehow it’s not passing the image.jpg file
It works if I copy the image to xcode iOS project. Did I miss some step?
a

agrosner

04/25/2023, 8:11 PM
Try to run pod install on the iOS app project. I had similar issue
If you do a search for the file, you should see it added to the Xcode project after running pod install
s

Sergio C.

04/25/2023, 8:49 PM
That worked! thanks Andrew.
The xml vector file was already added without this extra step. Jetbrains team should check if this can be done for image files too.
a

agrosner

04/25/2023, 9:02 PM
Np! I feel like the iOS assemble task should look at resource file changes and do a pod install if they’ve changed. I imagine it will come in future
n

Nikita Lipsky

04/26/2023, 5:21 PM
Of course!
s

Sergio C.

04/26/2023, 5:21 PM
great
j

John O'Reilly

04/30/2023, 9:22 AM
I wasn't clear from above if there's some dependency on using cocoapods to ensure image file gets copied over? I've tried a few different things but still getting
MissingResourceException
using following from JB sample as starting point...I've put that file in
commonMain/resources
as per sample
Image(
   painterResource("compose-multiplatform.xml"),
   null
)
ah, if I manually copy it in to the iOS project then it works
s

Sergio C.

05/01/2023, 2:34 PM
pod install is the correct way
j

John O'Reilly

05/01/2023, 2:36 PM
What if project isn't using cocospods? Or is there dependency on using it?
s

Sergio C.

05/01/2023, 2:38 PM
Good question, haven’t tried another method, the sample is using cocoapods and it’s the most common and used dependency manager on iOS
a

agrosner

05/01/2023, 5:10 PM
(For now) I believe SPM is the way of the future. But for now, pod install scripts will copy the resources into your Xcode project, thus why the step is necessary. It’s certainly somethingJB is probably going to add to the main assemble (if resource files change, recopy over)
q

Qamar A. Safadi

05/07/2023, 5:41 PM
Hey all, I am trying to pod install but it's not working... any ideas?
i

Ivan Fernandez

05/08/2023, 7:44 AM
i have the same issue with cococapods, pod install does not work for me,
a

agrosner

05/08/2023, 7:34 PM
Not sure what “doesn’t work” means. May help to be more specific 😊
i

Ivan Fernandez

05/09/2023, 10:15 AM
Yes, sorry, it finally works, but only if the resources are located in a shared module. I have another module for share resources only and for desktop and android it works but not for iOS (I am consuming this shareResources module in my share module)