FMDB wraps SQLite for Cocoa apps. It offers classes to open databases, run updates and queries, and queue access from multiple threads.
Overview
FMDB is an Objective-C layer on top of SQLite for Apple platforms. It presents SQLite as Cocoa-friendly classes so applications can create file, temporary, or in-memory databases, execute SQL, and read result sets without calling the C API directly.
Three main types organize usage: a database object for statements, a result set for SELECT output, and a serial queue that coordinates multithreaded access. Inserts and other non-SELECT statements use parameter binding rather than manual string escaping, and the API supports transactions and batched statement strings.
Swift and Objective-C projects can depend on FMDB through CocoaPods, Carthage, or Swift Package Manager. An optional SQLCipher integration path compiles encryption support and exposes methods to set keys and encrypt existing files.
Recent releases audit nullability for clearer Swift usage, expose several former methods as properties, and add helpers for custom SQL functions and URL-based database locations while remaining built on standard SQLite behavior.
Key features
- FMDatabase for SQL execution
- FMResultSet for query results
- FMDatabaseQueue for thread safety
- Parameterized statement binding
- Transaction support
- Optional SQLCipher encryption
- Swift Package Manager distribution
- Custom SQL function helpers
Use cases
- Local persistence in iOS apps
- Local persistence in macOS apps
- Encrypted SQLite with SQLCipher
- Multithreaded database access