Format:Core Data store
| Platforms | Platform:IOS, Platform:MacOS |
|---|---|
| Magic | SQLite format 3 ("SQLite format 3\0") |
| Extensions | .sqlite, .sqlite-wal, .sqlite-shm, .momd, .mom, .omo |
| Endianness | n/a (SQLite) |
| On this wiki | Facts · Code · Notes · Topics |
Apple's Core Data persistence layer in its default SQLite form: tables with a Z prefix (ZENTITYNAME columns Z_PK, Z_ENT, Z_OPT) plus Z_PRIMARYKEY, Z_METADATA and Z_MODELCACHE, described by a compiled model (.momd directory of .mom/.omo files) in the app bundle.
The table and column naming under Store is checked against iLEAPP's parsers; the Model and CloudKit statements below are still unverified general knowledge, so check them against a real store.
Store
The store is an ordinary SQLite 3 database (WAL mode by default, so also look for -wal and -shm files; recent data may live only in the WAL). Naming scheme, read in the iLEAPP artifact parsers (MIT, commit 16f2bc4): each entity becomes a table named Z plus the upper-cased entity name (entity KikUser is table ZKIKUSER, HistoryItem is ZHISTORYITEM); each attribute becomes a column ZATTRIBUTE; Z_PK is the integer primary key, Z_ENT the entity number and Z_OPT the optimistic-locking version (iLEAPP's foursquareSwarm.py excludes exactly Z_PK, Z_ENT and Z_OPT when listing data columns). Z_PRIMARYKEY has the columns Z_ENT and Z_NAME (the parsers run SELECT Z_ENT FROM Z_PRIMARYKEY WHERE Z_NAME = ?), so entity numbers differ per store and must be looked up, not hard-coded. Many-to-many relationships live in join tables named Z_<Z_ENT of the owning entity><RELATIONSHIP> (Z_2REMOTEPARTICIPANTHANDLES, and Z_9ADMINS with columns Z_9ADMINS and Z_9ADMINSINVERSE); iLEAPP rebuilds the name as Z_{z_ent}{suffix} and checks sqlite_master. The system tables are Z_PRIMARYKEY, Z_METADATA and Z_MODELCACHE (wickr.py skips exactly these three); iLEAPP's wifiNetworkStoreModel notes say the model version hashes sit in Z_METADATA, and netusage notes that a model cached in Z_MODELCACHE can be read to learn attribute types. Unverified: the Z_SUPER and Z_MAX columns of Z_PRIMARYKEY and the plist-blob format of Z_METADATA (no source read shows them).
Dates are stored as doubles in seconds since 2001-01-01 (the same epoch as Format:Property list (binary bplist00) dates); iLEAPP defines the Cocoa offset to Unix time as 978307200 seconds. Transformable and binary attributes are blobs that are often Format:NSKeyedArchiver archive or bplist data.
Source: https://github.com/abrignoni/iLEAPP (MIT) at 16f2bc480295140b7fba3e7562082295ecdc2b38, scripts/artifacts/foursquareSwarm.py, mastodon.py, callHistoryGroupCall.py, kikGroupadmins.py, wickr.py, wifiNetworkStoreModel.py, netusage.py; read, not run.
Model
The compiled model is a .momd folder in the app bundle (Foo.momd/Foo.mom, versions as separate .mom files plus VersionInfo.plist, optimized .omo). A .mom is an NSKeyedArchiver archive of NSManagedObjectModel (Unverified), giving entity, attribute and relationship names. Class names there match Objective-C or Swift NSManagedObject subclasses in the binary (Technique:Objective-C runtime metadata).
How to approach
Open with sqlite3, list tables, read Z_PRIMARYKEY, then map entity ids to tables; use the .mom names to give columns types. Apps may use CloudKit-mirrored stores, which add ZCK* / ATRANSACTION tables (Unverified).