Please forgive the fact that this question is coming from the wrong
direction, i.e., iPhone -> MacOSX i386
I have a Universal iPhone/iPad app that uses sqlite. At a point
in the app I need to get the Maximum ID for an entity in the
database.
The Project for this app includes:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libsqlite3.0.dylib
There is no corresponding dylib found beneath
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/MacOSX.platform
I want to use the same sqlite methods in a MacOSX program
When I include this same dylib in the i386 project, I get an error
that the file
ld: file not found: /usr/lib/system/libdispatch_sim.dylib for architecture i386
When I remove the reference to the dylib from the Xcode project, then I get
multiple errors with symbols not found , for example:
"_sqlite3_open", referenced from:
-[AppDelegate fetchMaxRecipeId] in AppDelegate.o
Do I need to compile a dynamic library from sqlite.c specific for i386 ??
if so, where do I find the right commandline
for gcc ???? Or is there a simpler fix. I am stumped.
Many Thanks, Mark
- (NSNumber*) fetchMaxRecipeId {
NSNumber *theMax;
sqlite3 *database;
NSString *databaseName = DATA_FILENAME_EXT;
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *dbPath = [documentsDir stringByAppendingPathComponent:databaseName];
//NSLog(@"2nd:documentsPath=%@\ndocumentsDir=%@\ndat abasePath=%@",documentPaths,documentsDir,dbPath);
// Open the database from the users filessytem
theMax = 0;
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
//const char *sqlStatement = "SELECT * FROM mynotes";// table name
const char *sqlStatement = "SELECT MAX( ZRECIPEID) FROM ZRECIPE";// table name
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
//[recipeNotes removeAllObjects];
/*
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *aNote = [NSString stringWithUTF8String

char *)sqlite3_column_text(compiledStatement, 3)];
NSNumber *aRid = [NSNumber numberWithInt

int)sqlite3_column_int(compiledStat ement, 2)];
// Create a note object with the data from the database
RecipeNote *aRecipeNote = [[RecipeNote alloc] initWithNote:aNote Rid:aRid];
// Add the mynotes object to the RecipeNote Array
[recipeNotes addObject:aRecipeNote];
[aRecipeNote release];
}*/
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
theMax = [NSNumber numberWithInt

int)sqlite3_column_int(compiledStat ement, 0)];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return theMax;
}