Core Data Lab 2.4: SwiftData and Composite attributes
Version 2.4 of Core Data Lab contains new features largely based on new data storage API’s announced by Apple at WWDC23. The table view column configuration context menu has been redesigned, partly inspired by a few new NSTableView features in macOS 14. And as always, there is a pretty long list of small but useful new features and enhancements.
SwiftData vs Core Data
Apple announced at WWDC23 the long-awaited UISwift-oriented declarative data storage framework named SwiftData. Under the hood it’s not really completely new because it operates largely on top of Core Data. The data is stored in a SQLite database using the familiar Core Data structure.
The data model of a SwiftData project is based on Swift class files with a Model macro notation, instead of entities in a Core Data Object Model designer file. As a consequence of this, compiled SwiftData apps don’t have an embedded compiled Core Data Object Model. This makes it impossible for Core Data Lab to search for a matching database by comparing the model of a database with the embedded model of a Core Data app. Core Data Lab uses instead some sparsely documented conventions to determine the location of the database files for a given SwiftData app.
The changes for SwiftData in Core Data Lab 2.4 adds support for:
- Browsing and opening SwiftData apps and databases in the Simulator browser for iOS, iPadOS, tvOS and visionOS apps.
- Detecting apps as SwiftData apps, including extraction of bundle and app group identifiers, necessary to find the related database files.
- Finding the database of a selected SwiftData macOS app via the Search database function, based on default SwiftData file location conventions.
New in Core Data when used with the latest OS versions, is support for NSCompositeAttributeType attributes. Core Data Lab 2.4 adds support for:
- Displaying composite values in the table, detail and content views as readonly dictionaries.
- Sorting on composite values in the table views.
- Using composite attributes in the Predicate editor. This means you can filter on any element of a composite attribute, including nested composite attributes.
- Export and import of composite attributes values via CSV or JSON import and export files.
- Tracking data changes in composite attributes when using the Data changes tracker feature.
- Displaying composite attributes in the Entity Description view of a selected entity.
We want to add editing support for composite attributes, plus more detailed metadata info in the Entity info dialog, in a future update.
Column configuration context menu
The right-click context menu of column headers has been redesigned and rewritten. It is inspired by a few NSTableViewDelegate features available in macOS 14, but than better and also supported on older versions of macOS. The new context menu makes it much easier to quickly hide the columns you don’t want to see, and only show the columns you’re interested in.
Column configurations are stored as part of Saved predicates. So in case you often need a particular column configuration of a certain entity, just click on the Predicate editor button in the toolbar, fabric a predicate that shows all data you need, and hit the Save button. Stored predicates are being added to the sidebar and are part of the Core Data Lab project.
This update contains the following additional new features and enhancements:
- The layout of Project Properties dialog has been streamlined to be similar to the other dialogs in the app. The dialog is also more communicative in case something is wrong with the project, like missing files.
- Navigation with the Tab keyboard key through all attributes in the Inspector panel has been improved when it contains one or more read-only binary or composite attributes.
- Core Data Lab now always checks the reachability of the opened database files when the document window is being reactivated. If necessary an auto-repair of the database file locations is being performed if it concerns a simulator project. Otherwise when the database files are no longer at the expected locations, the Project Settings dialog is being presented.
- Added support for handling non-inverse relationships.
- Extraction of app icons for displaying in the toolbar has been improved.
- The Simulator browser now supports display of visionOS apps and databases.
- Extended support for HEIC images in the Content viewer panel.
- Searching databases in the Search database dialog is now much faster with traditional Core Data apps when the search path is set to Containers. Instead of performing a full scale search, an initial limited search is done in the container folder of the selected app.
- Inspector panel toolbar handling is now based on new AppKit API when using macOS 14.
- Restored using UUID attributes in the Predicate editor.
- Fixed unlimited resizing of the Inspector.
- Fixed displaying binary fields in the Inspector with non-Core Data SQLite database.
- Experimental support for saving Binary field values as file via right click context menu of the attribute name in the Inspector.
Core Data Lab owners can download the update for free from the Mac App Store. If you are not yet a Core Data Lab user, you can try the app for free, 14 days long.