Simon Binder
03/21/2025, 9:58 AM<http://libsqlite3.ar|libsqlite3.ar>
by invoking clang through the KMP PlatformManager
and we include that with a cinterops definition having a staticLibraries
option.
3. We then export our project as an xcframework.
I know that our setup generally works because Kotlin tests depending on SQLite pass on all platforms we care about (and I checked with nm
that a copy of SQLite is part of the test executable there). When consuming the exported xcframework on a Swift project on macOS though, we get linker errors about missing symbols like sqlite3_column_database_name
or sqlite3_win32_set_directory
. What all the missing symbols have in common is that they're optional or platform-specific, so they're not enabled by default (column_database_name
needs SQLITE_ENABLE_COLUMN_METADATA
, for example).
From my understanding, the root cause is this:
1. The cinterop setup on SQLiter creates Kotlin functions for all symbols defined in sqlite3.h
.
2. When we test with Kotlin, we compile an executable from which unused symbols are removed by the linker (?), and since we're not calling sqlite3_column_database_name
anywhere, the undefined symbol is never part of the executable.
3. When exporting the library as a framework, the symbols aren't stripped and consumers can't link our framework?
Is there a way for us to fix this by e.g. removing unused symbols when creating the xcframework?Simon Binder
03/21/2025, 2:36 PM