Skip to content

Decodable Swiftdata

A proof-of-concept for building offline-first iOS apps with Codable conforming models

Decodable SwiftData

Read full article on Medium

Since Apple announced the new SwiftData framework at WWDC23, I’ve been SUPER eager to try it out. It’s a new framework that matches SwiftUI’s style and makes working with persistent data (CoreData) much easier. Now that it's out of beta, I spent an hour messing around with it and put together a quick proof-of-concept using this brand-spanking-new framework.

I specifically wanted to see how easy it would be to conform a persistent data model to the Codable protocol to make working with remote and local persisted data easier.

The following approach could be helpful if you’re building an offline-capable iOS app that works with remote data, persists on the device, and syncs with the server when connected to the internet.