Persistence, Core Data, files, caches, migrations, and secure storage
Storage is a set of contracts, not one database choice. Field Notes keeps searchable note metadata in a model store, large attachments as files, disposable thumbnails in a cache, small preferences in defaults, and credentials in Keychain.
Design the boundary
- SwiftData or Core Data fits durable queryable models. Files fit large bytes that need explicit lifecycle ownership.
- Cache eviction is normal. Durable data loss is an incident, so those errors need different recovery paths.
- Historical schema fixtures prove migration. A fresh latest schema proves only first launch.
- The Keychain adapter owns credential create, update, read, delete, and accessibility policy. Tests use a credential-free in-memory substitute.
Validation boundary
No SwiftData, Core Data, file-protection, or Keychain operation ran without a full Apple SDK environment.
Series navigation
- Previous: Part 79: Networking, authentication, real-time events, and resilience
- Next: Part 81: Security, privacy, permissions, and platform policy
- Series index: Zero to iOS Hero