Here is what SwiftData will be (…and what it could have been)

Image by https://pixnio.com/author/milim84

Core Data is not going anywhere

If you’re hoping for something completely new with SwiftData, I don’t think you are going to get it. Apple have invested many years into Core Data, and have a strong team working on it. The framework today is very stable, and much more powerful than most developers realize. You don’t really understand just how powerful Core Data is, until you start developing your own model layer from scratch. Then you start to hit the problems:

  • How do I make sure that there is only one copy of a particular object in memory?
  • How do I access enormous datasets without pulling everything into memory?
  • How do I make transactional updates to a set of objects?
  • How do I keep the data in memory up-to-date with what is on disk?
  • How can I make long running updates in the background, while my UI continues to use the same data store?
  • How do I merge in changes from other devices?

Learning from SwiftUI

If Core Data is not going anywhere, what place is there for SwiftData? Well, the same place as for SwiftUI.

SwiftData at WWDC2021

This is all well and good, but wasn’t this post about SwiftData? How did we get onto SwiftUI?

What it could have been

It sounds good, right? SwiftData will make working with your data model nicely integrate with the new SwiftUI framework you are using to layout your UI, and should be as robust as the latest releases of Core Data. It’s the most logical step for Apple to take, and that is why I think we will see it, if not this year, probably next.

Decentralized stores will rule the earth

Remember when you got your first Mac or iPhone? If you have been around a while, you will probably remember that it was a fairly isolated device. My first Mac didn’t connect to anything, not even the web. I could write documents, but they stayed right on the hard disk (or floppy, if you are really old!). There was no watch or phone to exchange data with. In the rare case that an app could work with a peripheral, such as an iPod, it required a direct USB connection to sync up the data each day.

Why are we still waiting?

It’s a good question. Given the technologies needed to make a decentralized store are not really that new, why haven’t we seen someone make one yet? Why is there no easy to use decentralized store for app developers?

WWDC2023

This is the potential. This is what SwiftData could have been. It’s almost certainly not what it will be, but perhaps it can be the next step. Gather the top engineers from the Core Data, CloudKit, and APFS teams, and start now, Apple. And at WWDC2023 we can all be astonished at how easy it now is to develop a cross device app, with complete user privacy guaranteed. We can use the framework to more easily develop apps that run on all of Apple’s devices, and Apple can sell it to the public as a great step forward in taking control of their personal data. Win, win.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store