Cristhian Escobar
06/30/2024, 8:14 PM> Task :shared:generateNonAndroidBuildConfig UP-TO-DATE
> Task :shared:kspKotlinIosArm64
i: [ksp] loaded provider(s): [androidx.room.RoomKspProcessor$Provider]
> Task :shared:kspKotlinIosSimulatorArm64
i: [ksp] loaded provider(s): [androidx.room.RoomKspProcessor$Provider]
> Task :shared:copyRoomSchemas NO-SOURCE
> Task :shared:compileKotlinIosSimulatorArm64
e: file:///Users/..../newm-mobile/shared/src/iosMain/kotlin/database/GetNewmRoomDatabaseBuilder.ios.kt:13:20 Type mismatch: inferred type is Unit but RoomDatabase was expected
e: file:///Users/....//newm-mobile/shared/src/iosMain/kotlin/database/GetNewmRoomDatabaseBuilder.ios.kt:13:20 Type mismatch: inferred type is Unit but NewmAppDatabase was expected
e: file:///Users/....//newm-mobile/shared/src/iosMain/kotlin/database/GetNewmRoomDatabaseBuilder.ios.kt:13:45 Unresolved reference: instantiateImpl
> Task :shared:compileKotlinIosSimulatorArm64 FAILED
> Task :shared:compileKotlinIosArm64 FAILED
e: file:///Users/..../newm-mobile/shared/src/iosMain/kotlin/database/GetNewmRoomDatabaseBuilder.ios.kt:13:20 Type mismatch: inferred type is Unit but RoomDatabase was expected
e: file:///Users/..../newm-mobile/shared/src/iosMain/kotlin/database/GetNewmRoomDatabaseBuilder.ios.kt:13:20 Type mismatch: inferred type is Unit but NewmAppDatabase was expected
e: file:///Users/..../newm-mobile/shared/src/iosMain/kotlin/database/GetNewmRoomDatabaseBuilder.ios.kt:13:45 Unresolved reference: instantiateImpl
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
// shared/src/androidMain/kotlin/Database.k
fun getRoomDatabaseBuilder(context: Context): RoomDatabase.Builder<NewmAppDatabase> {
val dbFile = context.getDatabasePath("newm-app.db")
return Room.databaseBuilder<NewmAppDatabase>(
context = context,
name = dbFile.absolutePath
)
}
// shared/src/iosMain/kotlin/Database.kt
fun getNewmAppDatabase(): RoomDatabase.Builder<NewmAppDatabase> {
val dbFile = NSHomeDirectory() + "/newm-app.db"
return Room.databaseBuilder<NewmAppDatabase>(
name = dbFile,
factory = { NewmAppDatabase::class.instantiateImpl() }
)
}
// shared/src/commonMain/kotlin/Database.kt
fun getNewmAppDatabase(
builder: RoomDatabase.Builder<NewmAppDatabase>
): NewmAppDatabase {
return builder
.fallbackToDestructiveMigrationOnDowngrade(dropAllTables = true)
.setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(Dispatchers.IO)
.build()
}