Closed joeldenke closed 7 months ago
Do you have a reproducer? I'm not really sure what we can do about this, it's a fairly standard function 🤔
Worth mention is this only happening when doing clean builds, for android + iOS. Like rebuild in IDE. And it appears as warnings. It still compiles. It started happening when I upgraded from 0.18.1 to 0.19.0 release, so something changed in that release impacting this.
The task in Gradle is: > Task :shared:linkDebugFrameworkIosSimulatorArm64
which having gradle setup:
plugins {
alias(libs.plugins.app.android.library)
alias(libs.plugins.app.compose.multiplatform)
alias(libs.plugins.app.kotlin.multiplatform)
alias(libs.plugins.app.compose.android)
alias(libs.plugins.kspGradle)
}
composeFeatures {
runtime()
foundation()
ui()
material3()
material3WindowSizeClasses()
componentResources()
}
kotlin {
targets.withType<KotlinNativeTarget>().configureEach {
binaries.framework {
isStatic = true
baseName = "AppKt"
}
}
sourceSets {
commonMain {
dependencies {
implementation(projects.core.common)
api(projects.ui.base)
implementation(projects.core.data)
implementation(libs.ktor.core)
implementation(libs.koin)
api(libs.slack.circuit.foundation)
api(libs.slack.circuit.backstack)
api(libs.slack.circuit.circuitx.gesture.navigation)
implementation(projects.feature.login)
implementation(projects.feature.user)
implementation(projects.feature.search)
implementation(projects.feature.todo)
implementation(projects.feature.home)
implementation(projects.feature.survey)
implementation(projects.feature.register)
}
}
androidMain {
dependencies {
api(libs.androidx.core.core.ktx)
api(libs.androidx.compat)
implementation(libs.koin.android)
api(libs.androidx.activity.compose)
implementation(libs.androidx.navigation.compose)
api(libs.androidx.lifecycle.runtime.compose)
api(libs.androidx.lifecycle.viewmodel.compose)
api(libs.androidx.lifecycle.viewmodel)
api(libs.androidx.lifecycle.viewmodel.ktx)
implementation(compose.preview)
implementation(compose.uiTooling)
}
}
}
}
android {
namespace = "se.app.shared"
}
Using this config for the target platforms in my KMP convention plugin applied, if that impacts:
targets.withType<KotlinNativeTarget>().configureEach {
binaries.configureEach {
linkerOpts("-lsqlite3")
freeCompilerArgs += "-Xdisable-phases=RemoveRedundantCallsToStaticInitializersPhase"
}
configureFreeCompilerArgsArguments(
"-Xallocator=custom",
"-Xadd-light-debug=enable"
)
compilations.configureEach {
compilerOptions.configure {
optIn.addAll("kotlinx.cinterop.ExperimentalForeignApi", "kotlinx.cinterop.BetaInteropApi")
}
}
}
targets.configureEach {
sourceSets.all {
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
}
configureFreeCompilerArgsArguments(
"-Xexpect-actual-classes"
)
}
Without a reproducer project I'm not sure there's much we can do. We'd need to send this to JB probably too and they'll want that too
Hmm Yeah I will see what I can do. Hopefully enough using default CMP template and use Circuit. Will try create small repro.
I am facing the same warning in my project, linking the repo.
And I am also unable to build the project with the below error in :composeApp:linkReleaseFrameworkIosArm64
, :composeApp:linkReleaseFrameworkIosX64
and :composeApp:linkReleaseFrameworkIosSimulatorArm64
steps and I am unable to build the app for iOS at all
e: Compilation failed: Index 0 out of bounds for length 0
* Source files:
* Compiler version: 1.9.22
* Output kind: FRAMEWORK
e: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source)
at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source)
at java.base/java.util.Objects.checkIndex(Unknown Source)
at java.base/java.util.ArrayList.get(Unknown Source)
Without a repro case there's not much we can do. This seems to be coming from the CM compiler
@ZacSweers Sorry for late reply, was some other things in my way had to deal with. Here is sample repo project. Its using version 1.6.0-rc03, but same result as in 1.6.0-rc02.
I ran into this issue as well and the iOS link step always failed with the "Symbol ... is unbound" error (no IndexOutOfBoundsException
). As a workaround I used the overload with the explicit class argument:
rememberAnsweringNavigator(navigator, Result::class) {
// ...
}
It seems only the @Composable inline fun <reified T>
overload is broken.
Would you mind filing a bug report on compose-multiplatform? This seems like a bug with the multiplatform compose compiler with reified functions
The index out of bounds thing, seems to be this: https://youtrack.jetbrains.com/issue/KT-64508/IndexOutOfBoundsException-in-Konan-StaticInitializersOptimization
Which can be solved with:
kotlin.targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
binaries.all {
freeCompilerArgs += "-Xdisable-phases=RemoveRedundantCallsToStaticInitializersPhase"
}
}
However thats not the same bug I experience, even though I see that as well sometimes. But yes seems to be Konan problems. Will try file a bug to CMP project as well.
Closing as this is not really a circuit bug
I'm seeing the same error when I upgrade to Kotlin 2.0 and Compose MP 1.6.10. Looks similar to the ticket open here for Compose: https://github.com/JetBrains/compose-multiplatform/issues/2900
When I do clean builds of a Compose multiplatform project, starting of Circuit version 0.19.0 getting odd warnings, see attached stacktrace. I however can build all targets, including iOS successfully.
Versions in use: Circuit: 0.19.0 Kotlin: 1.9.22 Compose multiplatform: 1.6.0-rc01
Stacktrace: