Introduction
So far we've built shared UI and run it on Desktop + Android. Now let's take the same code to iOS.
Step 1: Create ViewController in iosMain
MainViewController.kt (iosMain)kotlin
1fun MainViewController() = ComposeUIViewController {2 QuotesScreen()3}
Step 2: Hook into Swift
In iosApp
:
ContentView.swiftswift
1struct ContentView: UIViewControllerRepresentable {2 func makeUIViewController(context: Context) -> UIViewController {3 MainViewController()4 }5 func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}6}
Step 3: Run in Simulator
Quick Tip: Select iosApp run config in IntelliJ, or open in Xcode.
▶ Run → your app launches in iOS Simulator with the same UI.
Continue Learning: Move on to Part 4 to learn about adding real state management with a ViewModel-style approach for handling favorites.