Demonstrates integrating Compose Multiplatform UI into an iOS-only KMP project, where CocoaPods is used primarily to set up Compose for iOS.
- Shared UI for iOS: Build your application's UI using Compose Multiplatform and run it on iOS.
- CocoaPods for Compose: Utilize CocoaPods to integrate the Compose Multiplatform framework into the iOS project.
- KMP: Share UI and potentially ViewModels/logic within a single Gradle module.
:composeApp: The Compose App Gradle module.- Contains all shared Compose UI code (
commonMain). - Includes iOS-specific configurations and the entry point for Compose (
iosMain). build.gradle.ktsdeclares Compose Multiplatform dependencies and configures CocoaPods for Compose integration.
- Contains all shared Compose UI code (
:lorem-ipsum: A sample library module.- Contains shared code.
- Have a CocoaPods dependency.
:google-maps: A sample google maps library module.- Contains shared code.
- Have a GoogleMaps CocoaPods dependency.
iosApp: Native iOS application project (Xcode).- Hosts the Compose UI via a
UIViewController. - Consumes the framework produced by the
:composeAppmodule.
- Hosts the Compose UI via a
:composeApp/build.gradle.kts:- Kotlin iOS target.
cocoapodsblock configured to build the Compose framework for iOS.- Compose Multiplatform dependencies.
iosApp/ContentView.swift:- Calls the KMP entry point (e.g.,
MainViewControllerKt.MainViewController()) to embed the Compose UI.
- Calls the KMP entry point (e.g.,
- Prerequisites: Xcode, Intellij IDEA, CocoaPods.
- Build:
- Sync Gradle in Intellij IDEA (for the
:composeAppmodule). - In the
iosAppdirectory, runpod install. - Open the generated
.xcworkspacein Xcode and run on a simulator or device.
- Sync Gradle in Intellij IDEA (for the