LINKING TO THE SQLITE3 LIBRARY
To use a SQLite3 database in your application, you first need to add the libsqlite3.dylib library to your Xcode project. The following Try It Out demonstrates how. You will need to download the code files indicated for this exercise and the rest of the Try It Out features in this chapter.
TRY IT OUT: Preparing Your Project to Use SQLite3

- Using Xcode, create a new Single View Application (iPhone) project and name it Databases. Use the project name as the Class Prefix. Ensure that you have the Use Automatic Reference Counting option unchecked.
- Select the project name and then click the Build Phases tab on the right (see Figure 11-1). Click the “+” button shown in the Link Binary with Libraries section to add the libsqlite3.dylib library to it. After this, the library will be added to the project (see Figure 11-2).

FIGURE 11-1

FIGURE 11-2
- In the DatabasesViewController.h file, declare a variable of type sqlite3, as well as a few methods (see the code in bold). You will define the various methods throughout this chapter.
#import <UIKit/UIKit.h>
#import “sqlite3.h”
@interface DatabasesViewController : UIViewController
{
sqlite3 *db;
}
-(NSString *) filePath; ...