Thread
#multiplatform
    jean

    jean

    1 year ago
    I’m trying to get an instance of my sqldelight database on ios, but I haven’t figured it out yet. On android, i do this :
    val factory = DatabaseDriverFactory(context)
    val db = MyDatabase(factory.createDriver())
    return NewsDatabaseClient(db)
    and it works fine. But if I try this on ios:
    let factory = DatabaseDriverFactory()
    let db = MyDatabase(driver: factory.createDriver())
    let client = NewsDatabaseClient(database: db)
    I get the following error
    'MyDatabase' cannot be constructed because it has no accessible initializers
    Does anyone know how I’m suppose to create it?
    Yev Kanivets

    Yev Kanivets

    1 year ago
    I usually add Kotlin initializer in commonIOS submodule with
    NativeSqlDriver
    , and then call it from iOS’s ApplicationDelegate. But probably there are better ways for that.
    jean

    jean

    1 year ago
    I manage to make it work like so :
    NewsDatabaseClient(
        database:MyDatabaseCompanion.init().invoke(
            driver: DatabaseDriverFactory().createDriver()
        )
    )