Almost all our apps use Core Data to store all kinds of data. This means that during development, we often want to have direct access to the SQLite data from our Core Data apps, in order to check things, detect errors, diagnose problems, discover data trends, and more.
As a Core Data developer you can use regular SQLite viewers to access this data. But it is never really fun or convenient to work with these apps. They don’t know anything about the underlying Core Data Model, so they can't visualize data relationships, they display entities and fields with strange prefixes, show field values in an unpractical way. Many SQLite apps have not been maintained for years, or are not even native macOS apps, so you often have to get used to all kinds of strange GUI stuff.
There are already a few dedicated Core Data viewers. But these are often functionally limited, or have features that are already in Xcode, such as Core Data code generation, or have not been maintained for years and are therefore plagued with bugs and outdated GUI concepts.
So we started to develop a tool ourselves. Over the last few years, our in-house Core Data viewer has grown so much that it would be a waste to keep it to ourselves. So we decided to transform the tool into an attractive app for other developers, and place it on the Mac App Store for a reasonable fee. The proceeds will allow us to maintain the app properly, provide support and add new useful features.
The Core Data viewer app we had in mind should be able to filter data in any way we like, show related data defined by Core Data relationships, allow to edit and delete data, show any type of web data automatically, and present all data conform the object model including binary and transient fields.
A database viewer is of course not complete without obvious features like a metadata viewer, which allows you to inspect all aspects of the Core Data Object model, and export functions, which allow you to export any data selection as CSV or JSON file.
But there is more. The app should also be able to show all Core Data apps that we ever started in an iOS, iPadOS, tvOS or watchOS simulator in a handy overview, together of course with the related database. And we are always curious how ‘other’ apps uses Core Data. So our Core Data app should be able to find the database for a given Core Data app, and the other way around.
The resulting 1.0 version we now have includes all the features we originally wanted, plus more. The app has been developed as a NSDocument app, which means that it works project based, just like Xcode. A Core Data Lab project consists at minimum of a link to a Core Data app or model and a Core Data SQLite database. Other stuff stored in a project are NSPredicate filters, window positions, selections and more. A Core Data Lab project makes it easy to continue with your database research where you left off.
Another nice feature we implemented is a data change tracker, which lets you see in a graphical way how a Core Data app mutates a database. How does this work? Every save action on a managed object context after adding, changing or deleting data, results in a change of the database files. Every time this happens, a data comparison is performed by Core Data Lab between the previous and current data rows.
In tracking modus, the app display all changes in distinctive colours: green for new created data, purple for mutated data and red for deleted data. And if you don’t like the built-in color choices, then you can change them in the app preferences.
The future development of Core Data Lab depends on a mix of what we encounter ourselves while using our own app, the feedback we receive from other developers, and how Apple continues to extend the feature set of Core Data.
What we know for sure is that we want to extend the project file by storing even more environment aspects like custom column widths, sorting and visibility, panel sizes and visibility, and more. We will also want to add functions to add or even generate data, for (stress) testing purposes, including the possibility to add related data via a Core Data relationship. There are also all kinds of small things we like to improve, such as being able to use the tab key to go all through fields in the details panel or window.
To learn more about Core Data Lab, you may look at the following documentation:
Before you buy Core Data Lab at the Mac App Store, you can try the app for free, 14 days long.