sqldelight
sqldelight copied to clipboard
Incompatible with Kotlin 1.9.x
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)
}
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
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
Same error reproducing with Kotlin 1.9.20: https://github.com/softartdev/NoteDelight/actions/runs/6723531752/job/18273806995#step:8:708
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.
The error still occurs in sqldelight 2.0.1 https://github.com/softartdev/NoteDelight/actions/runs/7096127975/job/19314143203#step:8:697
Did you ever found out an workaround for this? I'm having the same problem with kotlin 1.9.22
The error still occurs in sqldelight 2.0.2 & kotlin 1.9.23. The previously found workaround still works.
@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 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.
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.