When considering using CMP with a kmp navigation l...
# compose-ios
c
When considering using CMP with a kmp navigation library, a CMP view inside SwiftUi Navigation, combinations of SwiftUI & CMP, etc. - how can go about understanding the implications for "life cycle" management? I'm already using KMP (with Koin) for shared business logic supporting a SwiftUI and Android Compose app. I'm now considering adding some new screens written in CMP. However, I'm not sure what questions I should be asking to understand the implications. Does anyone have any recommendations on what I can search / read up on to understand this more?
k
I started my hobby project with KMP and CMP and only after a month into the development I realized that the project template I started with actually had all the configuration changes on Android disabled. I was looking into it since at some points I started wondering why is a simple ‘remember’ doing a great job while it should’ve been ‘rememberSaveable’. Now it is still useful in case you use the rest of the multiplatform libraries, like navigation, viewmodel, etc (and even savedstatehandle, which sounds very android-specific). But when you have all these weird configuration changes out of your way (even though Google says you still cannot turn them all off), the conceptual part of the View/Composable lifecycle becomes pretty similar on both platforms. Basically, boils down to “Appearing/Entering Composition”, “Updating/Recomposing” and “Disappearing/Leaving Composition”. The answer depends on how are you going to use that CMP composable on different platforms. In my case my whole app is in CMP, but you will most probably wrap it in some kind of container and put it into your SwiftUI hierarchy (haven’t done this till now). So this container will most probably do the lifecycle “translation” between SwiftUI and Compose. As for resources, here are some really good ones from TouchLab: First, a talk on using CMP and SwiftUI together:

https://www.youtube.com/watch?v=7OIe8U2VVkA

Second, an experimental library which generates some of the boilerplate code from the talk above: https://touchlab.co/composeswiftbridge Also a tutorial https://touchlab.co/composeswiftbridge/tutorial and a blog post about it https://touchlab.co/compose-swift-bridge-launch The first video is the most informative one, since they explain their approach and strategy, so that you can understand what’s going on under the hood.
c
Thanks for the good summary@Karen Frangulyan - I'm trying out the swift-bridge stuff and might add it to my project 👍