views:

197

answers:

3

The concern is guaranteeing compatibility with the Sqlite Header file compiled into the iPhone app. What if the header file used at compile time is from a newer version then the dynamic library installed on the iPhone? This could be due to the app running on an older or newer iPhone OS version then the app was built with. Is it safe to use the Sqlite dynamic library on the iPhone? Or should we always statically link. BTW: Would rather not use Core Data.

A: 

SQLite is very careful about api compatibility. I think there are some very old apis that are marked as deprecated and non-functional but AFAIK they can still be called. That said, why not just include the amalgamation?

JeffreyABecker
A: 

The sqlite docs seem to recommend checking that the header file version is the same as the library version at: http://www.sqlite.org/c3ref/libversion.html. Worried because it doesn't seem like sqlite provides a contract/guarantee that things will keep working across versions. Besides deprecation there could be other types of incompatibility, regarding behavior or object size that could lead to crashes. As far the amalgamation that would add an additional 680K or so to the app. A pretty big hit for a mobile app.

Eric
A: 

First of all, the iPhone environment is tightly controlled by Apple, so you don't have to worry about a wide variety of SQLite libraries being installed on devices.

Second, when you use Xcode to link to a library you can choose to link against sqlite, sqlite3, sqlite3.6, etc. That way, if you are using a feature and cannot use anything earlier than 3.6, you can specify so in your app.

Third, SQLite is a stable project and you can trust that the authors won't make radical changes to the API without warning. If you link against sqlite3 you should be safe, unless you are doing some really weird.

Fourth, if you are doing something really weird, that relies on a quirk of a specific version of SQLite, then you should probably statically link to the library or stop doing that really weird thing.

In conclusion, yes, it is totally safe and recommended to dynamically link to the sqlite library on the iPhone, unless you are doing something really weird.

benzado