fmdb
A Cocoa / Objective-C wrapper around SQLite
FMDB is an Objective-C library that wraps SQLite for iOS and macOS apps, letting you query and update local databases through a clean API instead of low-level C functions, with built-in thread-safe access via FMDatabaseQueue.
FMDB is an Objective-C library for working with SQLite databases on Apple platforms, including iOS and macOS. SQLite is a local database built into Apple devices that stores structured data in a single file on the device. FMDB wraps SQLite in a more convenient Objective-C interface, making it easier to open, query, and update a database from within an iPhone or Mac app.
Without a wrapper, calling SQLite from Objective-C requires working with low-level C functions and managing memory manually. FMDB handles that plumbing so you can write database operations in a style that fits naturally with the rest of your Apple codebase. You open a database with an FMDatabase object, run SQL queries or updates through straightforward method calls, and iterate over results with a simple result set object.
The library includes FMDatabaseQueue, which handles the common scenario where multiple parts of an app try to read or write the database at the same time. SQLite does not allow concurrent writes from different threads; FMDatabaseQueue serializes those calls safely so they do not conflict.
FMDB can be added to a project through CocoaPods, Carthage, or Swift Package Manager. It works with both Objective-C and Swift, and supports both the older manual memory management style and the modern automatic reference counting approach. The library also integrates optionally with SQLCipher, a separate project that adds transparent encryption to SQLite databases, which is useful if the app needs to store sensitive data securely on the device.
The README notes this project is community-maintained. For full SQL reference, the project points developers to the SQLite documentation directly, since FMDB does not abstract away SQL itself. You still write SQL statements; FMDB just makes it easier to send them to the database and handle the results in Objective-C or Swift.
Where it fits
- Store and query structured local data in an iOS or macOS app using SQLite without writing low-level C code.
- Handle concurrent database access from multiple threads safely using FMDatabaseQueue to serialize reads and writes.
- Add encrypted SQLite storage to a sensitive iOS app using the optional SQLCipher integration.
- Replace raw SQLite C calls in an existing Objective-C or Swift project with a cleaner, more idiomatic API.