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.

CategoriesUncategorized