Skip to content

Installation

Decompose provides a number of modules, they are all published to Maven Central Repository.

The main Decompose module

The main functionality is provided by the decompose module. It contains some core features like ComponentContext, Child Stack, etc.

Gradle setup

implementation "com.arkivanov.decompose:decompose:<version>"
implementation("com.arkivanov.decompose:decompose:<version>")

Dependency on Essenty library

Some functionality is actually provided by Essenty library. Essenty is implemented by the same author and provides very basic things like Lifecycle, StateKeeper, etc. Most important Essenty modules are added to the decompose module as api dependency, so you don't have to add them manually to your project. Please familiarise yourself with Essenty library.

Extensions for Jetpack/JetBrains Compose

The Compose UI is currently published in two separate variants:

  • The one developed and maintained by Google is Android only, called Jetpack Compose
  • The Kotlin Multiplatform variant of Jetpack Compose maintained by both JetBrains and Google, we call it JetBrains Compose

Due to this fragmentation Decompose provides two separate extension modules for Compose UI:

  • extensions-compose-jetpack - Android library for Jetpack Compose
  • extensions-compose-jetbrains - Kotlin Multiplatform library for JetBrains Compose, supports android and jvm targets

Both modules are used to connect Compose UI to Decompose components. Please see the corresponding documentation page.

Gradle setup

Typically only one module should be selected, depending on the Compose UI variant being used.

implementation "com.arkivanov.decompose:extensions-compose-jetpack:<version>"
// or
implementation "com.arkivanov.decompose:extensions-compose-jetbrains:<version>"
implementation("com.arkivanov.decompose:extensions-compose-jetpack:<version>")
// or
implementation("com.arkivanov.decompose:extensions-compose-jetbrains:<version>")

Extensions for Android views

The extensions-android module provides extensions to connect Android views based UI to Decompose components. Please head to the corresponding documentation page for more information.

Gradle setup

implementation "com.arkivanov.decompose:extensions-android:<version>"
implementation("com.arkivanov.decompose:extensions-android:<version>")

Exporting Decompose to iOS Framework

For using Decompose on your iOS project you need to export it to the iOS Framework.

Regular Framework

...
kotlin {
    ...
    targets
        .filterIsInstance<KotlinNativeTarget>()
        .filter { it.konanTarget.family == Family.IOS }
        .forEach {
            it.binaries.framework {
                ...

                export("com.arkivanov.decompose:decompose:<version>")
                export("com.arkivanov.essenty:lifecycle:<essenty_version>")

                // Optional, only if you need state preservation on Darwin (Apple) targets
                export("com.arkivanov.essenty:state-keeper:<essenty_version>")

                // Optional, only if you need state preservation on Darwin (Apple) targets
                export("com.arkivanov.parcelize.darwin:runtime:<parcelize_darwin_version>")
            }
        }
    ...
}
...

CocoaPods

...
kotlin {
    ...
    cocoapods {
        ...
        framework {
            ...

            export("com.arkivanov.decompose:decompose:<version>")
            export("com.arkivanov.essenty:lifecycle:<essenty_version>")

            // Optional, only if you need state preservation on Darwin (Apple) targets
            export("com.arkivanov.essenty:state-keeper:<essenty_version>")

            // Optional, only if you need state preservation on Darwin (Apple) targets
            export("com.arkivanov.parcelize.darwin:runtime:<parcelize_darwin_version>")
        }
    }
    ...
}
...