I’ve been trying to configure sqldelight in my pro...
# multiplatform
j
I’ve been trying to configure sqldelight in my project since yesterday, but without any success so far
Copy code
plugins {
    kotlin("multiplatform") version "1.4.10"
    id("com.squareup.sqldelight")
}

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0")
        classpath ("com.squareup.sqldelight:gradle-plugin:1.4.3")
    }
}

sqldelight {
    database("MyDatabase") {
        packageName = "com.my.package.name.sqldelight"
    }
}
I also created a
News.sq
file in
src/commonMain/sqldelight/com/my/package/name/sqldelight
Running
gradlew build
succeed but I can’t see that
MyDatabase
class is generated. Am I suppose to do anything more?
m
update to 1.4.4 or run generateSqlDelightInterface as a gradle command. 1.4.4 automatically runs it when building
j
Still nothing generated 😞
a
they need to be in
src/main
instead of
src/commonMain
j
I still can’t access the
MyDatabase
class, when I use it like this for example (inside src/commonMain/kotlin) :
Copy code
fun createDatabase(driverFactory: DatabaseDriverFactory): MyDatabase {
    val driver = driverFactory.createDriver()
    return MyDatabase(driver)
}
building or running the different sqldelight tasks doesn’t change anything
a
your
.sq
files are in
src/main/sqldelight
?
j
yes
a
If you’re able to make a repro project please file an issue on github with a link to it
j
I’ve been trying to implement the driver factory regardless of the database class not being generated. I notice a few things : 1/ I couldn’t access the
Context
class because I was targeting the jvm for android. Now I target
android()
and it required a few changes. I’m able to create the
AndroidSqliteDriver
2/ The wizard for kmp library generated some weird/complex logic to figure out ios and native targets, without using the simple
ios { }
target, so I changed the logic to use that now. But I can’t access
NativeSqliteDriver
IntelliJ cannot find the reference even if I have the dependency:
Copy code
val iosMain by getting {
    dependsOn(clientCommon)
    dependencies {
        implementation("com.squareup.sqldelight:native-driver:1.4.4")
    }
}
this import isn’t working
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver