how to remove expect object for room database in m...
# room
h
how to remove expect object for room database in multiplatform:
Copy code
@Database(entities = [Employees::class, AssetTable::class], version = 1)
@ConstructedBy(AppDatabaseConstructor::class)
abstract class AppDatabase: RoomDatabase(){
    
}

// The Room compiler generates the `actual` implementations.
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect object AppDatabaseConstructor : RoomDatabaseConstructor<AppDatabase>
because when compile ./gradlew build always get error this
d
Which error are you exactly getting? Maybe you are missing the
override fun initialize(): AppDatabase
?
h
I not missing, but is there way not to use this:
Copy code
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect object AppDatabaseConstructor : RoomDatabaseConstructor<AppDatabase>
d
If you are on Android and JVM only you can skip it, otherwise for native you do need it for the DB to initialize.
h
@danysantiago problem is that i use kotlin multiplatform (android and ios), so I couldn't remove expect object AppDatabaseConstructor
d
If you are targeting iOS then you need the
expect object
so Room can initialize the DB in iOS. You don't use the class directly, Room will use it for you when you call
build()
on the database builder.
h
yeah i know it but it so annoying to put that. if could remove it later.