As said by @jbworld you cannot load dynamic libraries on the iPhone, so this link should be made statically, at compilation time. While reading at the code of spatialite (that's an SQLite extension), I found that kind of invocation:
void spatialite_init (int verbose) {
/* used when SQLite initializes SpatiaLite via statically linked lib */
sqlite3_auto_extension ((void (*)(void)) init_static_spatialite);
}
And the init_static_spatialite
code:
static void init_static_spatialite (sqlite3 * db, char **pzErrMsg,
const sqlite3_api_routines * pApi)
{
SQLITE_EXTENSION_INIT2 (pApi);
/* setting the POSIX locale for numeric */
setlocale (LC_NUMERIC, "POSIX");
*pzErrMsg = NULL;
sqlite3_create_function (db, "spatialite_version", 0, SQLITE_ANY, 0,
fnct_spatialite_version, 0, 0);
sqlite3_create_function (db, "proj4_version", 0, SQLITE_ANY, 0,
fnct_proj4_version, 0, 0);
sqlite3_create_function (db, "geos_version", 0, SQLITE_ANY, 0,
fnct_geos_version, 0, 0);
sqlite3_create_function (db, "GeometryConstraints", 3, SQLITE_ANY, 0,
fnct_GeometryConstraints, 0, 0);
sqlite3_create_function (db, "CheckSpatialMetaData", 0, SQLITE_ANY, 0,
fnct_CheckSpatialMetaData, 0, 0);
...
So it looks like if the sqlite_auto_extension
enables you to statically link an extension. The documentation seems to confirm that:
“This API can be invoked at program startup in order to register one or more statically linked extensions that will be available to all new database connections.”
Then, at runtime, for spatialite, I just have to invoke the spatialite_init(0)
to get the extension up and running.
Invoke such method before loading any sqlite DB.
Hope this helps.