sqldelight icon indicating copy to clipboard operation
sqldelight copied to clipboard

Incompatible with Kotlin 1.9.x

Open softartdev opened this issue 10 months ago • 10 comments

SQLDelight Version

2.0.2

Operating System

macOS

Gradle Version

8.7

Kotlin Version

1.9.x

Dialect

SQLite

AGP Version

8.3.1

Describe the Bug

There was a build error after upgrading my pet-project to Kotlin 1.9.0. Reproducing on Github-Action CI: https://github.com/softartdev/NoteDelight/actions/runs/5842453316/job/15843597101#step:8:753

Stacktrace

Task :shared:compileIosMainKotlinMetadata FAILED e: file:///.../*.kt Unresolved reference: SqlDriver e: file:///.../*.kt Unresolved reference: SqlSchema e: file:///.../*.kt Unresolved reference: QueryResult

Gradle Build Script

plugins {
    alias(libs.plugins.kotlin.multiplatform)
    alias(libs.plugins.kotlin.cocoapods)
    alias(libs.plugins.sqlDelight)
    alias(libs.plugins.android.library)
    alias(libs.plugins.mokoResources)
}
android { … }
multiplatformResources { … }
kotlin {
    jvmToolchain(11)
    jvm()
    androidTarget()
    iosArm64()
    iosSimulatorArm64()
    applyDefaultHierarchyTemplate()

    sourceSets {
        commonMain.dependencies { … }
        commonTest.dependencies { … }
        androidMain { … }
        val androidUnitTest by getting { … }
        iosMain.dependencies {
            implementation(libs.sqlDelight.native)
        }
        jvmMain.dependencies { … }
        jvmTest.dependencies { … }
    }
    cocoapods {
        summary = "Common library for the NoteDelight app"
        homepage = "https://github.com/softartdev/NoteDelight"
        ios.deploymentTarget = "14.0"
        pod("SQLCipher", libs.versions.iosSqlCipher.get())
        framework {
            isStatic = true
            export(libs.mokoResources)
        }
    }
}
sqldelight {
    databases {
        create("NoteDb") {
            packageName.set("com.softartdev.notedelight.shared.db")
        }
    }
    linkSqlite.set(false)
}

softartdev avatar Aug 13 '23 13:08 softartdev

The error still occurs in Kotlin 1.9.10. Reproducing on Github-Action CI: https://github.com/softartdev/NoteDelight/actions/runs/6102440527/job/16560922473#step:8:604

softartdev avatar Sep 06 '23 22:09 softartdev

Hello. I received the same error on the iOS build. Are there any updates or workarounds? This error was present both with 1.8.20 (22) and with 1.9.10

frontiertsymbal avatar Sep 26 '23 12:09 frontiertsymbal

Same error reproducing with Kotlin 1.9.20: https://github.com/softartdev/NoteDelight/actions/runs/6723531752/job/18273806995#step:8:708

softartdev avatar Nov 02 '23 08:11 softartdev

I found a workaround. Whether you call the legacy ios() function, which is deprecated and creates intermediate source sets under the hood, or create them manually, you then need to call the applyDefaultHierarchyTemplate() function. At least it works for my project. The cause of the error may be related to the source sets.

softartdev avatar Nov 25 '23 14:11 softartdev

The error still occurs in sqldelight 2.0.1 https://github.com/softartdev/NoteDelight/actions/runs/7096127975/job/19314143203#step:8:697

softartdev avatar Dec 05 '23 06:12 softartdev

Did you ever found out an workaround for this? I'm having the same problem with kotlin 1.9.22

vincent-paing avatar Mar 20 '24 12:03 vincent-paing

The error still occurs in sqldelight 2.0.2 & kotlin 1.9.23. The previously found workaround still works.

softartdev avatar Apr 10 '24 15:04 softartdev

@softartdev Unfortunately that workaround doesn't work for me. I'm still getting the issue when compiling for more than one ios-related target. Using sqldelight 2.0 and kotlin 1.9.23. Do you have any ideas for a slightly different workaround?

AlexanderEggers avatar Apr 11 '24 13:04 AlexanderEggers

@AlexanderEggers Try the workaround for each module that includes iOS-targets. Anyway, this requires a deep dive into the codebase of the library and plugins, I have little time, so just have to wait for the official fix.

softartdev avatar Apr 11 '24 15:04 softartdev

I think I found a tmp fix working for me:

val development: String by rootProject.extra
    if (development == "true") {
        iosSimulatorArm64("ios")
    } else {
        iosArm64("ios")
    }

Depending on my gradle.properties I'm using a specific target and match all ios targets to the same name. That clashes with the default template but seems to be working in my case.

AlexanderEggers avatar Apr 19 '24 17:04 AlexanderEggers