ios-data-persistence

Select and implement iOS and macOS data persistence with SwiftData, Core Data, GRDB, and CloudKit.

1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/Emasoft/emasoft-complete-ios-app-authoring --skill ios-data-persistence
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ios-data-persistence
Source: https://github.com/Emasoft/emasoft-complete-ios-app-authoring/tree/main/skills/ios-data-persistence
Command: npx skills add https://github.com/Emasoft/emasoft-complete-ios-app-authoring --skill ios-data-persistence

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill eliminates the high-cost, common problem of choosing the wrong data storage format or location for iOS/macOS apps, which leads to data loss, sync failures, backup bloat, App Store rejections, and hard-to-debug production crashes.

Core Features & Use Cases

  • End-to-end decision guidance: Step-by-step decision trees to select the correct storage format (structured records, files, key-value, secrets) and location (local, iCloud, Keychain) for any data type.
  • Multi-framework implementation guides: Detailed references for SwiftData, Core Data, GRDB, SQLiteData, CloudKit sync, iCloud Drive, Codable/JSON serialization, UserDefaults, file storage, and schema migrations, with production-ready code examples.
  • Anti-pattern and diagnostic support: Explicit warnings for common mistakes (e.g., mixing Core Data and SwiftData, unsafe migrations, CloudKit schema deployment gaps) and step-by-step diagnostic steps for sync failures, migration crashes, and data loss scenarios.
  • Use Case: For example, if you are building a cross-device task app, this Skill guides you to choose SwiftData + CloudKit for structured task records, iCloud Drive for user-exported PDFs, Keychain for auth tokens, and additive idempotent migrations for your existing user base, while avoiding pitfalls like tvOS local storage deletion.

Quick Start

Use the ios-data-persistence skill to select the correct storage solution for your iOS app's task data, implement SwiftData with CloudKit sync for cross-device access, and create safe additive schema migrations for your existing users.

Frequently Asked Questions about ios-data-persistence

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What's the best way to choose between SwiftData and Core Data for iOS data persistence?

Choosing between SwiftData and Core Data for iOS data persistence depends on your app's architecture and sync needs. SwiftData offers a modern Swift-native API, while Core Data provides mature, granular control. The Skill provides decision trees to select the correct structured database framework and avoid mixing them, which causes data loss.

How do I implement safe schema migrations for an existing iOS app database?

To implement safe schema migrations for an iOS app database, you must use additive and idempotent migration steps. The Skill provides implementation guides and anti-pattern warnings to ensure your SwiftData or Core Data schema updates do not cause data loss or migration crashes for your existing user base.

Why does CloudKit sync fail and cause data loss in my SwiftData app?

CloudKit sync fails and causes data loss in SwiftData apps often due to schema deployment gaps, offline-first workflow conflicts, or unsafe migrations. The Skill provides step-by-step diagnostic steps and anti-pattern warnings to resolve sync failures and ensure conflict-resilient iCloud workflows.

Can I use iCloud Drive for file storage and Keychain for auth tokens in a cross-device iOS app?

Yes, you can use iCloud Drive for user-exported file storage and Keychain for auth tokens in a cross-device iOS app. The Skill provides end-to-end decision guidance to map data to the correct storage location, ensuring structured records use SwiftData while files and secrets are stored separately.

When do I need GRDB or SQLiteData instead of Core Data for local persistence?

You need GRDB or SQLiteData instead of Core Data for local persistence when you require direct SQLite access or specific database features not exposed by higher-level frameworks. The Skill provides multi-framework implementation guides and decision trees to help you select the correct storage format for your specific data type.

What are the limitations of using UserDefaults for data persistence on iOS?

The limitations of using UserDefaults for data persistence on iOS include backup bloat and potential data loss when storing complex structured records instead of user preferences. The Skill provides anti-pattern warnings and configuration guidance to ensure UserDefaults is used appropriately and data is stored in the correct format.