Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when trying to use the SQLite wrapper FMDatabase

I'm having trouble when I try to use FMDatabase.

I have added theese files:

FMDatabaseQueue
FMDatabaseAdditions
FMDatabase
FMResultSet
FMDatabasePool

..and I have also added the libsqlite3.dylib library and imported FMDatabase.h, but as soon as I uncomment this line:

FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];

..I get this error:

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_FMDatabase", referenced from:
      objc-class-ref in DBWrapper.o
ld: symbol(s) not found for architecture i386

I have also tried changing settings like Deployment target between 4.0 - 5.0 and creating a new, clean project, etc.

I'm using Xcode Version 4.3 (4E109).

What am I doing wrong? :)

// Stefan

like image 834
Stefan Edberg Avatar asked Feb 29 '12 15:02

Stefan Edberg


1 Answers

That's a linker error—meaning, everything you fed the compiler was fine but once it came time to package all the compiled object code together into an executable it couldn't find the implementation for a class that was referenced in the code.

Dragging .m files into the project source list in Xcode should automatically add them to the "build phase", but if you did that and you're getting this error, check that they're in there: Click the top-level item in the left-side source list to get the project settings, click the target in the next pane, click the "Build Phases" column header in the next pane, then expand the "Compile sources" row. If the FM files aren't in there, click the + button at the bottom of the list and select them.

like image 117
davehayden Avatar answered Oct 13 '22 16:10

davehayden