Core Data Lab is an app to view and track the SQLite data of a Core Data app. It shows all entities, attributes and relationships conform the object model. The app includes tools to view, filter, edit and export data, to track data changes, to inspect the model, and more.
Core Data Lab is a project based app. All settings regarding selected database and object model combinations are stored in a project document file together with other settings like ad-hoc data filters.
If you want to watch an introduction about Core Data Lab, check out this cool and informative video on YouTube, created by @tundsdev.
To properly view the data inside a Core Data database, Core Data Lab needs the associated Core Data object model. This concerns a compiled object model with a .mom extension, not the object model file in your Xcode project. The compiled object model file is normally located in a sub folder ending with .momd in the Resources folder within an app bundle.
When Core Data generates a SQLite database based on the object model, the object model is also stored within the database as a cache. Core Data Lab can read this cached object model, but can also use the compiled object model file embedded in the app bundle.
There are several ways to make a new project in Core Data Lab:
The easiest way to start a new Core Data Lab project is by opening a Core Data SQLite database that contains a cached object model. This is nearly always the case when the database is saved by a recent Core Data framework version.
Please take note of the following:
If you app concerns an iOS, iPadOS, watchOS or tvOS app which has been run in a simulator, you can make a new Core Data Lab project by simply selecting the database and app combination in the Simulator browser.
After selecting a Core Data app, you can start a search action for matching databases.
After selecting a Core Data object model, you can start a search action for matching databases.
After selecting a Core Data database, you can start a search action for matching apps.
After selecting a database, you can manually select an app. Or vice versa.
After exporting the data of a Core Data app to an app container using the Devices and Simulators dialog in Xcode, you can use Core Data Lab to automatically open the database located in the container. App containers do have a .xcappdata extension and are described in Finder as 'Xcode Application Data Package'.
Alternatively you can also open app containers directly in Finder by using the right-click context menu item Open with > Core Data Lab.
The most flexible way to start a new Core Data Lab project is by using the Project assistant.
After making a new project, you can always adjust all choices you made earlier in the Project assistant.
The sidebar on the left side of the document window shows the following item categories:
You can filter items in the sidebar by using the filter box at the bottom of the sidebar.
The middle and main part of the Core Data Lab document window shows the data of the item selected in the sidebar, presented as a table grid view.
You can perform the following column adjustments on grid views:
Column adjustment of the main grid are saved as part of the Core Data Lab project when working with stored predicates.
If the project consists of a valid database and object model, you'll see two sub panels at the lower side of the document window. The first sub panel shows data related to the selected row according to the selected relationship in the dropdown situated on top of the sub panel. With this dropdown you can switch to another relationship, if available.
If the project consists of a valid database and object model combination, you'll see two sub panels at the lower side of the document window. The second sub panel is a field level viewer. It shows only the content of one field of the selected row in the main grid view or a selected row in the relationship view. The dropdown on top of the content viewer let you switch to any field of the entity of the selected row. Default the first field is being shown. The content view automatically detects and shows web site URL's, image URL's, XML URL's, JSON URL's. In addition to this it also detects and show the content of binary fields containing images, XML, JSON or PLIST data.
The panel on the right side shows all fields of the selected row in one vertical column. If you have opened the database with a valid object model, you can also edit the data, unless you have opened the database as read-only. As soon as you have changed a field value, a Cancel and Save button pair will be shown at the bottom of the Details view panel. Clicking Cancel will revert all data changes, clicking Save will store all changes you have made for the selected data row.
If you want to edit the data of a row in a more spacious view, then you can open a row in a separate window or tab. Double-click a row to open the data in a window, or use the context menu of a selected row to open the data in a tab.
If an entity is selected in the sidebar, you can filter the related data by using the Predicate editor, which becomes visible after clicking on the filter button in the toolbar.
Anytime data is saved in a Core Data managed object context connected to a SQLite based persistent store, the related database files will change. These changes are monitored by Core Data Lab and can be used to track data changes.
The tracking feature is available when a standard entity is selected in the sidebar. The feature is not compatible with parent or child entities, predicates or read-only databases.
Data of a selected row can be edited in the Details panel or a Details window, when the database is opened together with a valid Core Data object model.
You can add new data objects for the selected entity by making use of menu item Data > New Object. To add a new related object to the currently selected parent object and relationship combination, choose Data > New Related Object in the menu.
The panel on the right side of the project window shows all fields of the selected row in one vertical column. As soon as you change a field value, a Cancel and Save button pair will be shown at the bottom of the Details view panel. Clicking Cancel will revert all data changes, clicking Save will store all changes you have made for the selected data row.
If you want to edit the data of a row in a more spacious view, then you can open a row in a separate window or tab. Double-click a row to open the data in a window, or use the context menu of a selected row to open the data in a tab.
Data can be exported to JSON or CSV format, if the project contains a valid database and object model combination. Follow these steps to export data:
You can import files based on JSON or CSV format. Importing CSV requires macOS 12 or newer. Follow these steps to import data:
The structure and formatting of the import file must be identical to the files exported by Core Data Lab:
When importing CSV, make sure the file complies to these rules, in addition to the regular CSV rules:
null
.true
, false
or null
.Entity metadata of a selected entity in the sidebar can be inspected via menu Data > Entity Description, or by simply double-clicking on the entity item in the sidebar.
Database metadata of the current Core Data SQLite database can be inspected via menu File > Store Metadata.
The settings of a project can be inspected via menu File > Project Settings. Or you can simply click on the status label located at the right side of the status bar in the middle of the toolbar.
The project settings dialog shows the full paths of the database and object model or related app, their reachability status and whether the combination is compatible.
In addition to this you can change the following settings:
The following settings can be changed in the Preferences dialog, and apply to all projects:
The File Access section shows access paths needed for the search forms and simulator browser. If needed you can change any path by clicking on the Change button.
In the New Projects section you can change the default directory for saving new projects.