voyager icon indicating copy to clipboard operation
voyager copied to clipboard

Error compile in ios

Open hafiz013 opened this issue 1 year ago • 6 comments

Veyogar library version 1.0.1 koin version : 3.5.3 org.jetbrains.kotlin.multiplatform: 2.1.0 org.jetbrains.compose: 1.7.3

Error occurred while optimizing an expression:
CALL 'public abstract fun <set-value> (<set-?>: T of kotlinx.coroutines.flow.MutableStateFlow): kotlin.Unit declared in kotlinx.coroutines.flow.MutableStateFlow' type=kotlin.Unit origin=EQ
  $this: CALL 'internal final fun <get-lastScreenModelKey> (): kotlinx.coroutines.flow.MutableStateFlow<kotlin.String?{ cafe.adriel.voyager.core.model.ScreenModelKey? }> declared in cafe.adriel.voyager.core.model.ScreenModelStore' type=kotlinx.coroutines.flow.MutableStateFlow<kotlin.String?{ cafe.adriel.voyager.core.model.ScreenModelKey? }> origin=GET_PROPERTY
    $this: GET_VAR 'val this: cafe.adriel.voyager.core.model.ScreenModelStore [val] declared in cafe.adriel.voyager.koin.getScreenModel' type=cafe.adriel.voyager.core.model.ScreenModelStore origin=null
  <set-?>: GET_VAR 'val key: kotlin.String{ cafe.adriel.voyager.core.model.ScreenModelKey } [val] declared in cafe.adriel.voyager.koin.getScreenModel' type=kotlin.String{ cafe.adriel.voyager.core.model.ScreenModelKey } origin=null

hafiz013 avatar Jan 13 '25 02:01 hafiz013

Update voyager version and refer to this 515

zeeshanali-k avatar Jan 13 '25 08:01 zeeshanali-k

@zeeshanali-k not fix the issue

hafiz013 avatar Jan 14 '25 08:01 hafiz013

https://github.com/adrielcafe/voyager/issues/522#issuecomment-2670438959

Farhod-Tohirov avatar Feb 20 '25 04:02 Farhod-Tohirov

@Farhod-Tohirov could u please share the solution

hafiz013 avatar Feb 21 '25 05:02 hafiz013

@Farhod-Tohirov could u please share the solution

I just added rinku to that project )

kotlin = "2.1.0" ksp = "2.1.0-1.0.29" compose-plugin = "1.7.1" rinku = "1.3.2"

class KMPConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            ... // other code
            val kmpExtension = extensions.getByType<KotlinMultiplatformExtension>()
            configureKMPTargets(kmpExtension)
            with(kmpExtension) {
                sourceSets {
                    commonMain.dependencies {
                        api(libs.findLibrary("rinku").get())
                        implementation(libs.findLibrary("rinku.compose.ext").get())
                    }
                }
            }
            ...  // other code
        }
    }
}

internal fun Project.configureKMPTargets(extensions: KotlinMultiplatformExtension) =
    with(extensions) {
        androidTarget {
            compilerOptions {
                jvmTarget.set(JvmTarget.JVM_11)
            }
        }
        compilerOptions {
            apiVersion.set(KotlinVersion.KOTLIN_2_1) 
        }
        listOf(
            iosX64(),
            iosArm64(),
            iosSimulatorArm64()
        ).forEach {
            it.binaries.framework {
                baseName = [email protected]()
                isStatic = true
                export(libs.findLibrary("rinku").get())
            }
        }
    }
private fun Project.resolveFullName(): String {
    val nonRootParent = parent?.takeIf { it != rootProject } ?: return name
    return "${nonRootParent.resolveFullName()}_name"
}
internal fun KotlinMultiplatformExtension.sourceSets(
    configure: NamedDomainObjectContainer<KotlinSourceSet>.() -> Unit
) {
    (this as ExtensionAware).extensions.configure("sourceSets", configure)
}

Apply KMPConvention plugin

Farhod-Tohirov avatar Feb 21 '25 06:02 Farhod-Tohirov

he fix was bizarre but surprisingly effective—adding rinku as a dependency resolved Voyager’s iOS issues, likely by bridging a gap in Kotlin/Native interop or threading. Shoutout to @Farhod-Tohirov for the unconventional save!

iosMain {  
    dependencies {  
        implementation(libs.ktor.client.darwin)  
        implementation(libs.stately.common)  
        implementation("dev.theolm:rinku:1.3.2") // "WTF fix" that actually worked  
    }  
}  

gusstein avatar Apr 11 '25 22:04 gusstein