Hi, we're using SQLiter and SKIE and are facing so...
# touchlab-tools
s
Hi, we're using SQLiter and SKIE and are facing some linker issues. I think I understand the cause, but I'm not sure how to address this and I wonder if someone here might have ideas. For context, our setup is basically this: 1. We have a KMP library depending on SQLiter to access SQLite. 2. I don't think this is relevant to this issue, but we're linking sqlite3 statically because we need extension loading which is otherwise not available on macOS. We create a
<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?
The easiest thing might just be to fix this upstream 🙂 https://github.com/touchlab/SQLiter/pull/124