You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Latest builds of JetBrains Compose support native iOS and macOS targets. Let's try to add it to extensions-compose-jetbrains module. Since it's far from stable, a separate branch seems reasonable.
Status update: experimental -native-compose versions of Decompose with Compose for Darwin (Apple/iOS) are published from the compose-experimental branch, and have <version>-compose-experimental version suffix.
Reacted by Andrey Miroshnychenko, Christos Malliaridis, MikhailZisman, Alexander af Trolle, Isuru Rajapakse and Artur Mavlyuchenko
Hi @arkivanov, first of all thank you to create this amazing library. I have been trying to integrate Decompose in Kotlin Multiplatform Compose project. I tried my best to thoroughly review your documentation and samples. I am unable to resolve following error on iOS:
Task :shared:linkPodDebugFrameworkIosX64 FAILED
error: Following dependencies exported in the podDebugFramework binary are not specified as API-dependencies of a corresponding source set:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':shared:linkPodDebugFrameworkIosX64'.
Following dependencies exported in the podDebugFramework binary are not specified as API-dependencies of a corresponding source set:
@blueberry404 any module that is exported to the framework must be specific as api dependency, not implementation. You also missing the dependencies {} block. See the example.
Thank you for quick response. Sorry, missing dependency block was pasting typo at my end. Key was to use api dependencies for both in iOSMain. I am able to compile it now. Thank you!
I think exporting is only required if you want co use that APIs in the iOS project (Xcode). If you are just using it from Kotlin, then you shouldn't need to export Compose extensions. Just implementation should enough. You can try at least.
Looks correct @chrisjenx. Just one possible point to improve in case you find it useful. I find it cleaner to destroy the root component on willTerminateNotification, instead of the deinit block. Check out the example here.
linkPodDebugFrameworkIosX64 FAILED
I also had above reported error for several hours with the correct setup like on the example
turns out I use the 1.0.0 version for the essenty dependency, and it finally can compile after I update it to 1.1.0,
just in case anyone has the same issue as me :)
I changed to using the new AutomaticLifecycle, also not tried web yet, but we're using iOS in production now, not seen anything major that jumps out, need to test out persistance, but imo it seems pretty stable, iOS can probably not be considered "experimental" esp after moving to serilization plugin
Oh, it was only considered experimental because it was defined so by JetBrains. Now since we don't need org.jetbrains.compose.experimental.uikit.enabled=true anymore, the support of Compose for iOS will be moved to the stable branch in v3.0. Being tracked here: #451.
Reacted by Christopher Jenkins and Shabinder Singh
Hi! I'm trying to implement shared navigation in my KMP project with shared UI. It works fine with Android, but I encountered an error with iOS:
error: Overload resolution ambiguity:
public fun <C : Any, T : Any> Children(stack: ChildStack<TypeVariable(C), TypeVariable(T)>, modifier: Modifier = ..., animation: StackAnimation<TypeVariable(C), TypeVariable(T)>? = ..., content: (child: Child.Created<TypeVariable(C), TypeVariable(T)>) -> Unit): Unit defined in com.arkivanov.decompose.extensions.compose.jetbrains.stack
public fun <C : Any, T : Any> Children(stack: Value<ChildStack<TypeVariable(C), TypeVariable(T)>>, modifier: Modifier = ..., animation: StackAnimation<TypeVariable(C), TypeVariable(T)>? = ..., content: (child: Child.Created<TypeVariable(C), TypeVariable(T)>) -> Unit): Unit defined in com.arkivanov.decompose.extensions.compose.jetbrains.stack
App.kt:34:9: error: Cannot infer a type for this parameter. Please specify it explicitly.
App.kt:36:50: error: @composable invocations can only happen from the context of a @composable function
App.kt:36:50: error: @composable invocations can only happen from the context of a @composable function
RootComponent.kt:24:32: error: Type mismatch: inferred type is Any but com.arkivanov.essenty.parcelable.Parcelable /* = com.arkivanov.parcelize.darwin.Parcelable */ was expected
RootComponent.kt:24:32: error: Type mismatch: inferred type is Any but RootComponent.Configuration was expected
I suspect there is some problems with iOS dependencies, but I was unable to track the exact cause. My build.gradle looks like this. Please let me know if I am missing anything. Thank you.
kotlin {
targetHierarchy.default()
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
```
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
val decompose_version = "2.2.0-compose-experimental"
val essenty_version = "1.3.0"
export("com.arkivanov.decompose: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")
}
}
sourceSets {
val androidMain by getting {
dependencies {
implementation ("com.google.accompanist:accompanist-systemuicontroller:0.27.0")
}
dependsOn(commonMain.get())
}
named("commonMain") {
dependencies {
api(compose.foundation)
api(compose.animation)
val decomposeVersion = "2.2.0"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
implementation("com.arkivanov.decompose:decompose:$decomposeVersion-compose-experimental")
implementation("com.arkivanov.decompose:extensions-compose-jetbrains:$decomposeVersion-compose-experimental")
implementation("com.russhwolf:multiplatform-settings:1.1.1")
implementation("com.russhwolf:multiplatform-settings-no-arg:1.1.1")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
implementation("com.moriatsushi.insetsx:insetsx:0.1.0-alpha10")
//put your multiplatform dependencies here
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation("dev.icerock.moko:resources:0.23.0")
implementation("dev.icerock.moko:resources-compose:0.23.0")
implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")
}
}
}
sourceSets {
named("iosMain") {
dependencies {
val decompose_version = "2.2.0-compose-experimental"
val essenty_version = "1.3.0"
api("com.arkivanov.decompose:decompose:$decompose_version")
api("com.arkivanov.essenty:lifecycle:$essenty_version")
}
}
}
PROBLEM: When adding the decompose extensions and sync gradle, an error occurs:
Thanks!
Method org/gradle/accessors/dm/LibrariesForLibs_Decorated.getExtensions()Lorg/gradle/api/plugins/ExtensionContainer; is abstract
Exception is:
java.lang.AbstractMethodError: Method org/gradle/accessors/dm/LibrariesForLibs_Decorated.getExtensions()Lorg/gradle/api/plugins/ExtensionContainer; is abstract
object AndroidSdk {
const val MIN = 24
const val COMPILE = 34
const val TARGET = COMPILE
}
build.gradle.kts (Project)
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.googleServices) apply false //generar y agregar el json primero y luego descomentar
// alias(libs.plugins.kotlinxSerialization)
}
Activity
arkivanov commentedon Apr 14, 2022
Created the branch: compose-darwin.
arkivanov commentedon Apr 15, 2022
The compiler crashes on CI, filed: JetBrains/compose-multiplatform#2007
[-]Compose native iOS and macOS support[/-][+]Compose for iOS, macOS and Web[/+]arkivanov commentedon Feb 2, 2023
Web (Canvas) support is now enabled. The new branch for all experimental targets is compose-experimental.
blueberry404 commentedon May 6, 2023
Hi @arkivanov, first of all thank you to create this amazing library. I have been trying to integrate Decompose in Kotlin Multiplatform Compose project. I tried my best to thoroughly review your documentation and samples. I am unable to resolve following error on iOS:
Here are the chunks of my build.gradle.kts:
I also tried to add dependencies like here, but no luck probably because it doesn't use cocoapods.
Please let me know if I am missing anything. Thank you.
arkivanov commentedon May 6, 2023
@blueberry404 any module that is exported to the framework must be specific as
apidependency, notimplementation. You also missing thedependencies {}block. See the example.blueberry404 commentedon May 6, 2023
Thank you for quick response. Sorry, missing dependency block was pasting typo at my end. Key was to use
apidependencies for both in iOSMain. I am able to compile it now. Thank you!arkivanov commentedon May 6, 2023
Awesome! Glad it worked. Most likely you don't need to export
extensions-compose-jetbrains, as it contains extensions specifically for Compose.blueberry404 commentedon May 6, 2023
Actually, I am going to write the common compose code for Android and iOS using jetbrain's compose, therefore I thought this is also I needed.
arkivanov commentedon May 6, 2023
I think exporting is only required if you want co use that APIs in the iOS project (Xcode). If you are just using it from Kotlin, then you shouldn't need to export Compose extensions. Just
implementationshould enough. You can try at least.blueberry404 commentedon May 6, 2023
Ok I get your point now. I will try and let you know. Thank you!
8 remaining items
arkivanov commentedon Jul 7, 2023
Looks correct @chrisjenx. Just one possible point to improve in case you find it useful. I find it cleaner to destroy the root component on
willTerminateNotification, instead of thedeinitblock. Check out the example here.rezyfr commentedon Sep 13, 2023
linkPodDebugFrameworkIosX64 FAILEDI also had above reported error for several hours with the correct setup like on the example
turns out I use the 1.0.0 version for the essenty dependency, and it finally can compile after I update it to 1.1.0,
just in case anyone has the same issue as me :)
chrisjenx commentedon Nov 22, 2023
I changed to using the new AutomaticLifecycle, also not tried web yet, but we're using iOS in production now, not seen anything major that jumps out, need to test out persistance, but imo it seems pretty stable, iOS can probably not be considered "experimental" esp after moving to serilization plugin
arkivanov commentedon Nov 22, 2023
Oh, it was only considered experimental because it was defined so by JetBrains. Now since we don't need
org.jetbrains.compose.experimental.uikit.enabled=trueanymore, the support of Compose for iOS will be moved to the stable branch in v3.0. Being tracked here: #451.chrisjenx commentedon Nov 23, 2023
Awesome, thank you for your superb work!
markvtailor commentedon Dec 4, 2023
Hi! I'm trying to implement shared navigation in my KMP project with shared UI. It works fine with Android, but I encountered an error with iOS:
I suspect there is some problems with iOS dependencies, but I was unable to track the exact cause. My build.gradle looks like this. Please let me know if I am missing anything. Thank you.
arkivanov commentedon Dec 4, 2023
@markvtailor it's difficult to help without the reproducer or at least the code. Feel free to file a separate issue with the additional information.
arkivanov commentedon Dec 9, 2023
Starting with Decompose 3.0.0-alpha01 all Compose variants are supported without any version suffixes.
chrisjenx commentedon Dec 9, 2023
🥳 Nice work!
malliaridis commentedon Apr 7, 2024
@arkivanov are the Docs outdated about WASM (see here)? May be addressed in #610 if that is the case.
arkivanov commentedon Apr 7, 2024
Thanks for pointing that out! The docs should be fixed now.
Germansdev commentedon Sep 18, 2024
Arkinov: Thank you very much for your great work!
PROBLEM: When adding the decompose extensions and sync gradle, an error occurs:
Thanks!
Method org/gradle/accessors/dm/LibrariesForLibs_Decorated.getExtensions()Lorg/gradle/api/plugins/ExtensionContainer; is abstract
Exception is:
java.lang.AbstractMethodError: Method org/gradle/accessors/dm/LibrariesForLibs_Decorated.getExtensions()Lorg/gradle/api/plugins/ExtensionContainer; is abstract
build.gradle.kts(composeApp)
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.androidApplication)
alias(libs.plugins.compose.compiler)
}
repositories {
google()
mavenCentral()
}
kotlin {
androidTarget()
....
//decompose:
implementation(libs.decompose)
implementation(libs.extensions.compose)
implementation(libs.essenty.lifecycle)
...}
androidMain.dependencies {
implementation(libs.decompose)
...}
iosMain.dependencies {...}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.kotlinx.coroutines.swing)
}
android {
namespace = "cmp.project.free_market"
compileSdk = AndroidSdk.COMPILE
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
}
dependencies {
implementation(libs.androidx.ui.graphics.android)
implementation(libs.androidx.media3.exoplayer)
implementation(libs.androidx.navigation.runtime.ktx)
implementation(libs.firebase.firestore.ktx)
implementation(libs.firebase.storage.ktx)
implementation(libs.androidx.ui.desktop)
implementation(libs.androidx.ui.unit.desktop)
implementation(libs.androidx.core)
}
compose.resources {
publicResClass = true
packageOfResClass = "me.sample.library.resources"
generateResClass = always
}
compose.desktop {
application {
mainClass = "cmp.project.free_market.MainKt"
}
object AndroidSdk {
const val MIN = 24
const val COMPILE = 34
const val TARGET = COMPILE
}
build.gradle.kts (Project)
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.googleServices) apply false //generar y agregar el json primero y luego descomentar
// alias(libs.plugins.kotlinxSerialization)
}
repositories {
google()
mavenCentral()
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/releases/")
}
}
libs.versions.toml:
[versions]
activityCompose = "1.9.1"
agp = "8.5.2"
compose-plugin = "1.6.11"
kotlin = "2.0.10"
gservices = "4.4.2"
decompose = "3.1.0"
#extensionsCompose = "3.1.0"
essenty = "2.1.0"
....
[libraries]
decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose" }
#extensions-compose = { module = "com.arkivanov.decompose:extensions-compose", version.ref = "extensionsCompose" }
essenty-lifecycle = { module = "com.arkivanov.essenty:lifecycle", version.ref = "essenty" }
...
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
googleServices = { id = "com.google.gms.google-services", version.ref = "gservices"}
Decompose extensions for Jetpack/Jetbrains Compose
-keep class com.arkivanov.decompose.extensions.compose.jetbrains.mainthread.SwingMainThreadChecker
gradle-wrapper.prperties:
#Wed Sep 18 09:03:09 ART 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
gradle.properties:
kotlin.code.style=official
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options="-Xmx2048M"
#Android
android.nonTransitiveRClass=true
android.useAndroidX=true
#Kotlin Multiplatform
kotlin.mpp.enableCInteropCommonization=true
#To hide warning message log cannot be built on this machine..ios..
kotlin.native.ignoreDisabledTargets=true
org.gradle.unsafe.accessors=false
org.gradle.java.home=C:/Users/Willkommen/.jdks/corretto-17.0.7
arkivanov commentedon Sep 18, 2024
Please try renaming
extensions-composeto e.g.decompose-extensions-composein yourlibs.versions.toml.Germansdev commentedon Sep 18, 2024
Thanks twice Master Arkivanov (quick and solved my karma!!) You are amazing.