This is a Kotlin Multiplatform project template with Decompose configured.
Note Due to the current state of iOS support this template uses experimental versions of Decompose. If you have any issues, please report them on GitHub.
You can use this template to start developing your own Decompose application targeting desktop, Android, and iOS, either by using Compose as shared UI across all platforms, or by using platform-specific UI like SwiftUI and Android XML.
The instructions below provide you additional information on how to work with this template and add features like navigation, state preservation and more.
The result will be a Kotlin Multiplatform project that uses the Decompose framework for common logic with the UI framework(s) of your choice and the features you need.
This project was inspired by the sample project of Decompose and the Compose Multiplatform Template.
In order to work with this template you need the following tools:
- Android Studio
- (Optional) The Kotlin Multiplatform Mobile plugin
Additionally, if you plan to write and run iOS-specific code on simulated or real devices, you need the following:
- A machine running a recent version of macOS
- Xcode
Tools like KDoctor can assist you during the installation process.
The project consists of multiple modules:
This is a Kotlin module that contains the shared logic of all platforms. This also includes the Decompose implementation.
This is a Kotlin module that contains the UI written with Compose Multiplatform that is shared across all platforms.
It depends on the shared
module as it uses the component interfaces from Decompose.
This is a Kotlin module that contains and builds the desktop (JVM) application.
It makes use of the shared code from the modules shared
and compose-ui
.
This is a Kotlin module that contains and builds the Android mobile application.
It makes use of the shared code from the modules shared
and compose-ui
.
This is a Kotlin module that contains and builds the iOS mobile application.
It makes use of the shared code from the modules shared
and compose-ui
.
This is a Swift project that build an iOS mobile application.
This module uses only the shared
module and SwiftUI for its UI (instead of Compose).
Note In practice you normally have either
app-ios-compose
orapp-ios-swift
.Therefore, do not hesitate to merge them or delete one of the two.
Depending on the platform you want to build for and run the project on, different gradle tasks may be used.
When using Android Studio you can simply select app-android
from the run configurations and run
the app.
./gradlew :app-desktop:run
./gradlew :app-ios-compose:iosDeployIPhone12ProDebug
Note See build.gradle.kts
deployConfigurations
for more information.
If you have installed the Kotlin Multiplatform Mobile plugin you can simply select app-ios-swift
from the run configurations and run the app.
Alternatively you can open app-ios-swift/app-ios-swift.xcodeproj
in XCode and launch the project
from there.
We encourage you to explore Decompose's features further and try adding them into your project:
- Add basic navigation with child stack(s) to your project
- Add child slots for loading one child at a time, or none
- Add back button handlers for intercepting back button presses
You can also have a look at various integrations, including:
- State preservation with Essenty and Parcelize (not available yet)
- Integration of MVIKotlin for sharing code using MVI pattern (not available yet)