1 / 11
Get local data right on iOS: choose the right storage, store settings, files, and secrets safely, master SwiftData (models, relationships, queries, #Predicate, ModelActor, VersionedSchema migrations, history) and Core Data (contexts, fetching, batch operations, persistent history, staged…
SwiftData, Core Data, CloudKit Sync, Files, and the Keychain
Read before you buy: the PDF here is a free sample — the first 20 pages of the 484-page book (payments, sales and reviews on this demo site are sample data). Get the full e-book at thenexbooks on Gumroad.
Your app is only as trustworthy as the way it stores data.
Lost edits, a list that slows to a crawl as it grows, an update that crashes on launch because the store could not migrate, two devices that quietly disagree — these are persistence problems, and they are the ones users never forgive. Apple gives you excellent tools: UserDefaults, files and Codable, the Keychain, SwiftData, Core Data, CloudKit, App Groups, and SQLite underneath it all. This book shows you which tool fits which job, how they work together, and how to keep your data correct as your app evolves.
This is not a beginner's tour of SwiftUI. We assume you can build a simple app and go deep on data: modeling, querying, background work under Swift 6, schema migrations, change history, performance, sync, sharing, protection, recovery, and testing — in both SwiftData and Core Data, because real teams maintain both.
What's inside
- The iOS storage landscape and a clear decision guide: UserDefaults, files, Keychain, SwiftData, Core Data, SQLite, and CloudKit
- The app sandbox: Documents, Application Support, Caches, tmp, backups, and App Group containers
- Preferences with UserDefaults and @AppStorage, documents and backups with Codable and atomic writes, and secrets with Keychain Services
- SwiftData in depth: @Model, relationships and delete rules, @Query, FetchDescriptor, #Predicate, editing with validation and undo, and large data such as photos
- SwiftData in production: @ModelActor background imports under Swift 6, VersionedSchema and migration plans with custom stages, the history API, #Unique and #Index, and performance techniques
- Core Data in depth: the model editor, NSPersistentContainer, managed object contexts and concurrency, NSFetchedResultsController and @FetchRequest, batch insert/update/delete, persistent history, and lightweight, staged, and custom migrations
- iCloud sync: CloudKit essentials, NSPersistentCloudKitContainer, SwiftData with CloudKit and the model rules sync requires, and custom sync with CKSyncEngine
- App Groups: sharing a store and settings with a widget and App Intents safely
- SQLite directly from Swift with prepared statements, plus where GRDB fits
- Data protection classes, backups, privacy manifests, and recovering gracefully when a store will not open
- Testing persistence with Swift Testing: in-memory stores, importers, backups, and migration tests
- A safe, step-by-step migration from Core Data to SwiftData
One running example, start to finish. You build the data layer of Shelfmate, a fictional home inventory app that tracks rooms, items, prices, serial numbers, photos, tags, and warranties. It starts with settings and a JSON backup and grows into a versioned SwiftData store with background import, change history, iCloud sync, a warranty widget, and a test suite — while a Core Data edition with the same data lets you compare the two frameworks line by line and finally migrate between them. The sample data is small enough to check by hand, and every number in the book is consistent from chapter to chapter.
Current and honest. Code targets the Swift 6 language mode with recent versions of Xcode and a deployment target of iOS 18; features introduced with iOS 26 are clearly marked and hedged. The book contains no invented benchmarks or statistics, and it tells you plainly where Apple's behavior may change between releases. Raw SQL examples were run against a real SQLite database. Every chapter includes complete code, Tips, Notes, Warnings, exercises, and Key Takeaways, and the appendices give you a cheat sheet, templates and reference tables, a production checklist, and a glossary.
Format: PDF, 484 pages (A4), linked table of contents and bookmarks. English. First Edition, 2026. Published by thenexbooks. Building iOS apps requires a Mac with Xcode. Apple, iOS, Swift, SwiftUI, SwiftData, Core Data, CloudKit, iCloud, and Xcode are trademarks of Apple Inc. This book is independent and is not affiliated with, sponsored by, or endorsed by Apple Inc.
Table of Contents
Part I — Foundations of Local Data
- Ch 1 · The iOS Storage Landscape: Choosing the Right Tool for Every Kind of Data
- Ch 2 · The Sandbox, Containers, and FileManager
- Ch 3 · UserDefaults and @AppStorage: Preferences Done Right
- Ch 4 · Files and Codable: JSON, Property Lists, Atomic Writes, and Backups
- Ch 5 · The Keychain: Storing Secrets Safely
Part II — SwiftData Essentials
- Ch 6 · SwiftData Fundamentals: @Model, ModelContainer, and ModelContext
- Ch 7 · Modeling Shelfmate: Attributes, Relationships, and Delete Rules
- Ch 8 · Querying with @Query, FetchDescriptor, and #Predicate
- Ch 9 · Editing Data in SwiftUI: Forms, Validation, Undo, and Saving
- Ch 10 · Photos and Large Data: External Storage, Files, and Thumbnails
Part III — SwiftData in Production
- Ch 11 · Background Work with ModelActor and Swift 6 Concurrency
- Ch 12 · Schema Versioning and Migrations with VersionedSchema
- Ch 13 · Tracking Changes: SwiftData History and Keeping Processes in Sync
- Ch 14 · SwiftData Performance: Efficient Fetches, Indexes, Uniqueness, and Batch Work
Part IV — Core Data in Depth
- Ch 15 · Core Data Fundamentals: The Model Editor, Entities, and NSPersistentContainer
- Ch 16 · Managed Object Contexts and Concurrency
- Ch 17 · Fetch Requests, NSFetchedResultsController, and @FetchRequest
- Ch 18 · Batch Operations, Persistent History, and Core Data Performance
- Ch 19 · Core Data Migrations: Lightweight, Staged, and Custom
Part V — Sync and Sharing
- Ch 20 · CloudKit Essentials for Persistence: Containers, Databases, Records, and Accounts
- Ch 21 · Syncing Core Data with NSPersistentCloudKitContainer
- Ch 22 · SwiftData and CloudKit: Model Rules, Setup, and Sync Behavior
- Ch 23 · Custom Sync with CKSyncEngine
- Ch 24 · App Groups: Sharing Data with Widgets, App Intents, and Extensions
Part VI — Production Data
- Ch 25 · SQLite Directly: The C API, Verifiable SQL, and When to Reach for GRDB
- Ch 26 · Data Protection, Backups, Privacy, and Recovering from Failure
- Ch 27 · Testing Persistence: In-Memory Stores, Swift Testing, and Migration Tests
- Ch 28 · Migrating from Core Data to SwiftData, and the Complete Shelfmate
Appendices
A · Persistence Cheat Sheet
B · Templates and Reference
C · Production Checklist
D · Glossary
Book details
| Detail | |
|---|---|
| Pages | 484 |
| Format | PDF (A4) |
| Language | English |
| Level | Intermediate to Advanced |
| Edition | 1st Edition (2026) |
| Download on this site | Free sample, first 20 pages (PDF) |
| Publisher | thenexbooks |
Files you get
No reviews yet. Only buyers can review.
More from thenexbooks