Hello everyone, i’m facing an issue while creating...
# multiplatform
n
Hello everyone, i’m facing an issue while creating archive from xcode for testflight, however it working fine on simulators and physical ios devices… please let me know what could cause this issue? thank you!!!
Copy code
Type-safe project accessors is an incubating feature.
> Task :xcodeVersion UP-TO-DATE
> Task :composeApp:checkKotlinGradlePluginConfigurationErrors
> Task :composeApp:compileKotlinIosArm64 UP-TO-DATE
> Task :composeApp:linkReleaseFrameworkIosArm64
error: Compilation failed: Index 0 out of bounds for length 0

 * Source files: 
 * Compiler version: 1.9.21
 * Output kind: FRAMEWORK

error: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
	at java.base/java.util.Objects.checkIndex(Objects.java:361)
	at java.base/java.util.ArrayList.get(ArrayList.java:427)
	at org.jetbrains.kotlin.backend.konan.optimizations.StaticInitializersOptimization$InterproceduralAnalysis.getCalledInitializer(StaticInitializersOptimization.kt:246)
	at org.jetbrains.kotlin.backend.konan.optimizations.StaticInitializersOptimization$InterproceduralAnalysis.analyze(StaticInitializersOptimization.kt:120)
	at ..............

> Task :composeApp:linkReleaseFrameworkIosArm64 FAILED
error: Compilation finished with errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':composeApp:linkReleaseFrameworkIosArm64'.
> Compilation finished with errors
👀 1
1
j
I have the same issue, however only when launch iOS from Android Studio, but works in XCode or Fleet to launch/build. Curious to hear more about this. Sorry I cant help, just tried to fix it myself but without luck.
n
seems like it’s an kotlin issue, i was using circuit so find an already reported issue for it. https://github.com/slackhq/circuit/issues/1075 issue track : https://youtrack.jetbrains.com/issue/KT-64508/IndexOutOfBoundsException-in-Konan-StaticInitializersOptimization Solved the issue by using this code snippet.
Copy code
kotlin.targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
    binaries.all {
        freeCompilerArgs += "-Xdisable-phases=RemoveRedundantCallsToStaticInitializersPhase"
    }
}
gratitude thank you 1
🎉 1
j
Nice, glad to hear you found a solution! :)