I added Room to a KMP project (targeting Android a...
# room
b
I added Room to a KMP project (targeting Android and iOS), and since then, Xcode Previews for my iOS app fail, with several errors around sqlite. Has anyone else run into this problem? I have tried adding
-lsqlite3
to the "Other Linker Flags" build setting, but the problem persists. That shouldn't be necessary, because I am using the BundledSqliteDriver ... I have also tried using the NativeSqliteDriver, but I get the same results Error message looks like:
Copy code
Undefined symbols for architecture arm64:
      "_sqlite3_mutex_held", referenced from:
          _sqlite3_sqlite3_mutex_held_wrapper226 in RailBirdKit[81](libandroidx.sqlite:sqlite-framework-cinterop-sqlite3-cache.a.o)
      "_sqlite3_mutex_notheld", referenced from:
          _sqlite3_sqlite3_mutex_notheld_wrapper227 in RailBirdKit[81](libandroidx.sqlite:sqlite-framework-cinterop-sqlite3-cache.a.o)
      "_sqlite3_unlock_notify", referenced from:
          _sqlite3_sqlite3_unlock_notify_wrapper252 in RailBirdKit[81](libandroidx.sqlite:sqlite-framework-cinterop-sqlite3-cache.a.o)
      "_sqlite3_win32_set_directory", referenced from:
          _sqlite3_sqlite3_win32_set_directory_wrapper181 in RailBirdKit[81](libandroidx.sqlite:sqlite-framework-cinterop-sqlite3-cache.a.o)
      "_sqlite3_win32_set_directory16", referenced from:
          _sqlite3_sqlite3_win32_set_directory16_wrapper183 in RailBirdKit[81](libandroidx.sqlite:sqlite-framework-cinterop-sqlite3-cache.a.o)
      "_sqlite3_win32_set_directory8", referenced from:
          _sqlite3_sqlite3_win32_set_directory8_wrapper182 in RailBirdKit[81](libandroidx.sqlite:sqlite-framework-cinterop-sqlite3-cache.a.o)
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
I resolved this issue. In my shared module's build.gradle.kts, I had been specifying a static framework:
Copy code
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64()
).forEach {
    it.binaries.framework {
        baseName = "MyAppKit"
        isStatic = true
    }
}
I had tried removing the static flag before, and adding a linker option for sqlite:
Copy code
it.binaries.framework {
        baseName = "MyAppKit"
        linkerOpts.add("-lsqlite3")
    }
But that also did not work. The working solution is to remove the static flag, and NOT set linker options:
Copy code
listOf(
    iosX64(),
    iosArm64(),
    iosSimulatorArm64()
).forEach {
    it.binaries.framework {
        baseName = "MyAppKit"
    }
}