How To Make Codable Work With Swift’s New Observation Framework and the @Observable Macro in SwiftUI

With Swift 5.9 and Xcode 15 introduced in this year’s WWDC, there is a new take on how observation is implemented and integrated with SwiftUI. The new macro capability in Swift has enabled the replacement of the protocol ObservableObject and property wrappers like @Published, @ObservedObject and @StateObjectwith the new @Observable macro. The new Observation framework brings several advantages, aiming for simpler usage and improved performance by updating only the views directly affected by changes in the data model.

Check out the documentation for a comprehensive introduction to the Observation framework.

Dynamic Lists With SwiftUI Using Swift Concurrency for Asynchronous Data Loading

In a previous blog post, I described an implementation of lists in SwiftUI where items are loaded dynamically as the user scrolls and additional data for each item is fetched asynchronously. I also wanted to provide a reusable infrastructure for lists where you could concentrate only on the data fetching logic and the presentation of a single list item, but didn’t quite reach that goal.

In this blog post, I try to improve the list infrastructure and the separation of concerns between the data model and UI. I also want to test the Swift Concurrency features (async/await etc) for the asynchronous parts, and see how well it plays with SwiftUI.