Apple is currently shipping SQLite 3.1.3 in Mac OS 10.4, but SQLite 3.3.5 is
much better.  Anybody with a Mac and Developer Tools installed can build a
the latest version of SQLite as a library in 5 minutes.

The hard part was getting my project to use it instead of
/usr/lib/libsqlite3.dylib (version 3.1.3) which comes with Mac OS 10.4.
According to some advice I got from Apple DTS, to "insure" that your app to
uses the version in its package instead of a dylib installed on the system
using the same name and symbol set, you should build and ship it as a
*static* library.

The following builds a static library of sqlite's C API from the latest
source code, which you can then use in other Xcode projects.  (It does not
build the command-line tool.)

*  Activate Xcode.  I have Xcode 2.2.1.
*  menu File > New Project > Static Library > BSD Static Library.  Name the
project "sqlite3".  (Xcode will add the prefix "lib" and the extension ".a"
to the product).
*  Browse to http://sqlite.org/download.html#cvs
*  Download the link named something like "sqlite-source-x_x_x.zip" which is
described as the "pure C code".
*  You will get a folder named something like "sqlite-source-X_X_X" which
contains .c, .h and one .def files.
*  Move this folder into the project folder of your new Xcode project.
*  In Xcode project window, select the "sqlite3" group at the top and click
menu > Project > Add to project.
*  Navigate to and choose the "sqlite-source-X_X_X" directory in your new
project's folder.
*  In Xcode project window, select the "sqlite3" group at the top, click the
gear pulldown menu and select Add > New Group.
*  Give your new group a name, I suggest: "Frameworks".
*  Select this new group and click menu > Project > Add to project.
*  Navigate to and choose /System/Library/Frameworks/Tcl.framework
*  In Xcode, menu > Project > Set Active Build Configuration > Release
*  In the Groups and Files pane, expand Target and doubleclick on sqlite3 to
show the target settings.  Click the "Build" pane.  Find "Installation
Directory" and change it from "/usr/local/lib" to
"@executable_path/../Libraries"
*  In the Groups and Files pane, expand Products > sqlite > Copy Headers.
Change the Role of sqlite.h to "public".
*  cmd-B to Build.
*  You'll get four warnings about "build" directories not existing, but
ignore these.
*  You should get "Build succeeded".
*  cmd-B again and you should immediately get a clean "Build succeeded"
because the warned-about "build" directories will have been created during
the first build.

In any project which depends directly on this sqlite build,

*  Add the just-built libsqlite3.a to your project
*  In the Target, Build settings, find the "Other Linker Flags" Setting and
enter the Value "-Wl,-search_paths_first".
*  While you're there, check that the path to it has been added in the
Target > Build > Libary Search Paths
*  #include "sqlite3.h" where needed.

In the final product project (which may be the same as above)

*  Add a "Shell Script Build Phase" to copy the libsqlite3.a you have
produced to the product's Contents/Libraries/.  (There may be other ways to
"Copy Files", but I don't trust Xcode.  I like my shell scripts because I
know what they're going to do.)
*  To verify that everything worked, log the value of the global char*
variable sqlite3_version.

The Tcl framework which I used is symlinked to the latest version of Tcl,
which is 8.4 in Mac OS 10.4.  The product of the above procedure seems to
work in Mac OS 10.3 too; at least, the library loads and responds to
sqlite_version() when the app runs.  I have not done any real testing in
10.3 yet.


Reply via email to