The earlier -Wl,-U,_sqlite3_enable_load_extension fix only satisfied the linker; at runtime, Kotlin/Native's cinterop wrapper for that function still resolves against the symbol the moment SQLDelight's native-driver opens a connection, and Apple's system libsqlite3 doesn't export it on macOS — so the app now crashed instead of failing to build. Adds weak no-op definitions of sqlite3_enable_load_extension and sqlite3_load_extension, compiled directly into the app (Xcode's file-system-synchronized group picks the file up with no project.pbxproj changes needed beyond what Xcode itself rewrote on this build). Weak means a platform whose system library does provide the real symbol keeps using that one; this only fills in where it's missing. Verified there's no longer a crash by running the built macOS binary directly and by installing/launching it on the iOS Simulator — neither produced a dyld error or a crash report, versus two reproducible crash reports beforehand with the exact reported failure signature. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QpjMKWGoiT5aJBzhxvXkwp
25 lines
1.1 KiB
C
25 lines
1.1 KiB
C
#include <sqlite3.h>
|
|
#include <stddef.h>
|
|
|
|
// Apple's system libsqlite3 omits extension-loading support on some platforms (notably macOS,
|
|
// deliberately, for security), yet SQLDelight's native-driver still references these symbols —
|
|
// Kotlin/Native's cinterop generates a wrapper for every function declared in sqlite3.h,
|
|
// regardless of whether anything actually calls it, and this app never loads SQLite extensions.
|
|
// Without a definition somewhere, that missing symbol fails at link time (or, if the linker is
|
|
// told to allow it, crashes dyld the moment the app runs and Kotlin's wrapper resolves it).
|
|
//
|
|
// These are weak, so on a platform where the real system symbol does exist, it's used instead;
|
|
// this fallback only takes over where the real one is missing.
|
|
__attribute__((weak))
|
|
int sqlite3_enable_load_extension(sqlite3 *db, int onoff) {
|
|
return SQLITE_OK;
|
|
}
|
|
|
|
__attribute__((weak))
|
|
int sqlite3_load_extension(sqlite3 *db, const char *zFile, const char *zProc, char **pzErrMsg) {
|
|
if (pzErrMsg != NULL) {
|
|
*pzErrMsg = NULL;
|
|
}
|
|
return SQLITE_ERROR;
|
|
}
|