swiftdata

Persist, query, and migrate Swift @Model classes with SwiftData.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/harshav167/build-ios-apps --skill swiftdata-harshav167
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftdata
Source: https://github.com/harshav167/build-ios-apps/tree/main/skills/swiftdata
Command: npx skills add https://github.com/harshav167/build-ios-apps --skill swiftdata-harshav167

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

SwiftData enables modeling, persisting, querying, and migrating data in Swift-based apps, providing a native, strongly-typed API for iOS data stores and CloudKit integration.

Core Features & Use Cases

  • Define @Model classes with @Attribute, @Relationship, @Transient, @Unique, and @Index
  • Query data with @Query, #Predicate, FetchDescriptor, and SortDescriptor
  • Configure ModelContainer/ModelContext for SwiftUI, background work, and @ModelActor
  • Plan migrations with VersionedSchema and SchemaMigrationPlan
  • Coexist with or migrate from Core Data, and set up CloudKit sync
  • Seamlessly integrate with SwiftUI components and previews

Quick Start

Use SwiftData by annotating models with @Model and wiring a ModelContainer to enable persistence, queries, and migrations in your app.

Frequently Asked Questions about swiftdata

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

FAQPage Schema
How do I configure SwiftData persistence and queries in a SwiftUI app?

Configure SwiftData persistence by defining @Model classes and wiring a ModelContainer to your SwiftUI app. This setup enables strongly-typed data stores, querying with @Query, and background operations using @ModelActor.

What is the best way to migrate a Core Data app to SwiftData?

Migrate Core Data to SwiftData by planning schemas with VersionedSchema and SchemaMigrationPlan. SwiftData supports direct coexistence with Core Data, allowing you to transition your persistence layer incrementally without losing existing data.

Does SwiftData work with CloudKit for syncing?

Yes, SwiftData works with CloudKit for syncing. You can configure your ModelContainer to enable CloudKit integration, allowing your defined @Model classes to synchronize automatically across a user's iOS devices.

How do I use FetchDescriptor and #Predicate for SwiftData queries?

Use FetchDescriptor with #Predicate to perform SwiftData queries. This strongly-typed API allows you to filter, sort with SortDescriptor, and retrieve persisted @Model objects directly within your Swift code or SwiftUI views.

Can I optimize SwiftData performance for large binary data?

Optimize SwiftData performance for large binary data by using external storage attributes. Annotating your @Model properties appropriately ensures that large Data objects are stored efficiently without bloating in-memory contexts.

When do I need VersionedSchema for SwiftData migrations?

You need VersionedSchema when your app's @Model definitions change and require a SchemaMigrationPlan. This mechanism handles lightweight and custom migrations, ensuring persisted data adapts safely to new model structures.