Sample app to demonstrate how to encode/decode Firestore document data to Core Data
NSManagedObject
subclass usingCodable
API, and use@FetchRequest
to display data in SwiftUI views.
Since Firestore's support for Swift's Codable API, it became easier to map Firestore data to any object that conforms to Codable protocol, but NSManagedObject
subclass does not conform to Codable
, and we have to do that manually.
Firestore and Codable Core Data NSManagedObject in SwiftUI
- Mapping Firestore Data in Swift - The Comprehensive Guide
- Using Codable with Core Data and NSManagedObject
- Working with Codable and Core Data
- @DocumentID not populated with custom codable implementation
- Update CoreData in init(from:)
- iOS 16.6+
- Xcode 15
- Swift 5.9