Error when trying to use the SQLite wrapper FMDatabase Error when trying to use the SQLite wrapper FMDatabase sqlite sqlite

Error when trying to use the SQLite wrapper FMDatabase


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.


Expanding on davehayden's answer...

If you add a folder of header and source files into Xcode, the .m files are not added to the Compile Sources list. I usually get caught out here because I want to retain a sensible folder structure in my project folder. To get around this, I manually copy the files into my project folder where I want them. Then in Xcode, add each individual header and source file to my project without copying (using File > Add Files To...). Select all the loose files in the Project Navigator, right click, and make a folder from selection.

A bit late, but I hope this helps someone else.


Have you imported the FMDB headers in the place that you're using them?

#import "FMDatabase.h"