https://kotlinlang.org logo
Title
r

Richard L Zarth III

04/18/2023, 3:22 PM
Does anyone have a good writeup or documentation for how Compose Multiplatform for iOS works? As in: how does code/rendering get transformed from Compose to UIKit and/or SwiftUI code/rendering (not from a How Do I standpoint but from a curiosity standpoint)? Any resources would be appreciated, thanks. 🙂
s

Stefan Oltmann

04/18/2023, 3:25 PM
Nothing gets transformed. The approach is rather simple and the same like Flutter or Compose Desktop: Rendering using SKIA to a canvas. Same is true for Compose for Web.
Transforming to SwiftUI would be a possibility, but that way you would have to deal with all the limitations of SwiftUI. For example in SwiftUI you can't set a scrollstate to a scrollview. If you have a working Android/JVM app using that feature the Apple version would lack this functionality if Compose UI would be converted/adapted to SwiftUI.
r

Richard L Zarth III

04/18/2023, 3:31 PM
So to make sure that I understand: Compose Multiplatform takes its components, renders them via Skia on a
Canvas
, and then for iOS creates a
UIViewController
whose
UIView
is just a "drawing board" for that
Canvas
. So from the UIKit perspective there is just one
UIViewController
and
UIView
at all times essentially. Does that seem accurate?
s

Stefan Oltmann

04/18/2023, 3:31 PM
That's how I understood that process, yes.
The UIView is the canvas in that case. On JVM it's a JComponent (Swing) that serves as the canvas.
But I would also be interested in resources that explain how exactly SKIA is utilized to draw to UIView and JComponent.
a

Alejandro Rios

04/18/2023, 3:33 PM
Here's a related topic, it might help
r

Richard L Zarth III

04/18/2023, 3:35 PM
Thanks. 👍
s

Stefan Oltmann

04/18/2023, 3:49 PM
r

Richard L Zarth III

04/18/2023, 4:21 PM
Thanks. 👍
d

Dima Avdeev

04/19/2023, 7:27 AM
Some info about Compose for iOS architecture available on KotlinConf talk:

https://youtu.be/03T-ARIo0t8?t=18811

Later we will provide some additional docs about the usage of Compose for iOS. (But not about arhitecture)
r

Richard L Zarth III

04/20/2023, 3:45 PM
Thanks for the video. I'll check it out.