Hello guys. I am trying to set up Room DB for KMM and it works fine for the android however, when I ...
j

Joe Altidore

11 months ago
Hello guys. I am trying to set up Room DB for KMM and it works fine for the android however, when I add this dependency block
dependencies {
    add("kspAndroid", libs.room.compiler)
    add("kspIosSimulatorArm64", libs.room.compiler)
    add("kspIosX64", libs.room.compiler)
    add("kspIosArm64", libs.room.compiler)
}
add("kspAndroid", libs.room.compiler)
works fine but when I add the the last three it and attempt to sync gradle, I get this error
A problem occurred configuring project ':composeApp'. Cannot change attributes of configuration ':composeApp:debugFrameworkIosX64' after it has been locked for mutation
Furthermore, when replace the block above with this
dependencies {
    add("kspAndroid", libs.room.compiler)
    afterEvaluate {
        add("kspIosSimulatorArm64", libs.room.compiler)
        add("kspIosX64", libs.room.compiler)
        add("kspIosArm64", libs.room.compiler)
    }
}
gradle sync works but iosMain Data base configuration doesn't generate. This is the ios Database config function
private fun getDatabase(): PropertyDatabase {
    val dbFile = NSHomeDirectory() + "/property.db"

    return Room.databaseBuilder<PropertyDatabase>(
        name = dbFile,
        factory = { PropertyDatabase::class.instantiateImpl() }
    ).setDriver(BundledSQLiteDriver())
        .fallbackToDestructiveMigration(false)
        .build()
}
PropertyDatabase::class.instantiateImpl()
line shows an error when I try to rebuild because the instantiateImpl() is not generating `