iOS 27 introduces HistoryObserver in SwiftData, enabling clean one-way synchronization between a local SwiftData store and a custom backend. The tutorial walks through building a room measurement app that detects inserts, updates, and deletes via persistent transaction history, batches changes into RoomPayload objects, and uploads them to a Node/Express REST API. Key techniques covered include tracking a lastToken bookmark to avoid reprocessing old transactions, persisting that token in UserDefaults, batching payloads for efficiency, and implementing soft deletes (marking records with isDeleted before actual removal) to ensure the server is notified before local deletion. The lastToken is only updated after a successful server response to prevent skipping unsynced changes.

14m read timeFrom azamsharp.com
Post cover image
Table of contents
Source Code
139 Impressions