Home / Insights / Mobile App Development

Mobile App Development

SwiftData and Modern iOS Persistence: Choosing Storage for a New iOS App

SwiftData arrived with iOS 17 and promises persistence with far less code than Core Data. For a new iOS app, though, the right storage choice depends on your minimum OS version, sync needs, data shape and how much risk you can accept from a young framework. This guide sets out the options and a way to decide.

TopicsMobile App Development

Key takeaways

  • SwiftData requires iOS 17 or later; if you must support iOS 16 or earlier, Core Data or a SQLite library is the practical choice.
  • Most apps need several stores, not one: a model store for structured data, the Keychain for secrets, files for large media and UserDefaults for small preferences.
  • Decide early whether the server or the device is the source of truth; caching server data and syncing user-created content are different problems with different designs.
  • iCloud sync through SwiftData or Core Data imposes schema rules (no enforced unique constraints, optional relationships, additive-only production schemas) that are hard to retrofit.
  • Prototype the hardest query, a schema migration and a background import before committing, and keep persistence behind a repository layer so the decision can be revisited.

Every iOS app that remembers anything between launches makes a storage decision, and it is one of the hardest to reverse. Once real users have data on their devices, changing frameworks means writing migration code that must work on every version of the schema you have ever shipped. A poor early choice shows up later as slow screens, sync conflicts, lost edits after an update or months of rework.

This article is for CTOs, founders and product leads planning a new iOS app in 2024. It explains what SwiftData changes, how it compares with Core Data, SQLite, plain files and the Keychain, and how to choose based on your minimum OS version, sync requirements and data shape. It ends with an implementation plan and a checklist you can hand to your iOS lead or to the team you are hiring to build the app.

What SwiftData changes, and what it does not

Apple describes SwiftData as a framework that lets you write model code declaratively to add managed persistence. In practice you mark a Swift class with the @Model macro, its stored properties become the schema, and a ModelContainer and ModelContext handle storage, fetching, inserts, updates and deletes. In SwiftUI, the @Query macro fetches models and keeps views updated when the data changes.

Three facts matter for planning:

  • It builds on Core Data. Apple’s documentation says SwiftData combines Core Data’s persistence technology with Swift’s concurrency features, and its iCloud sync uses Core Data’s NSPersistentCloudKitContainer. It is a new programming model over a mature engine, not a new database.
  • It requires iOS 17 or later (and macOS 14, watchOS 10, tvOS 17, visionOS 1). If your audience includes devices that cannot run iOS 17, SwiftData is not an option for those users.
  • It has had less time in production. SwiftData shipped in autumn 2023. Core Data has been available since iOS 3. Young frameworks change quickly between OS releases, and some behaviours your app depends on may differ between iOS 17.0 and later point releases.

What you gain

Less code and fewer files: no separate model editor file, no generated classes, and a schema that lives next to your Swift types. SwiftUI integration is direct. Undo support, relationships with delete rules, versioned schemas for migration and optional iCloud sync are available. For a team starting a SwiftUI app on iOS 17, that is a meaningful productivity gain.

What you still have to design

SwiftData does not decide your source of truth, conflict policy, sync with your own backend, encryption of sensitive data or how large media is stored. Those remain architectural decisions, and they matter more than the framework choice.

The storage options on iOS and what each is for

Most production apps use several stores at once. The mistake is forcing all data into one of them.

OptionBest forMinimum iOSWatch out for
SwiftDataStructured app data in new SwiftUI apps; caching server data; user content with optional iCloud synciOS 17Young framework; fewer escape hatches; CloudKit schema rules
Core DataStructured data where you need older OS support, fine control of contexts, batch operations or staged and manual migrationsLong-standing (since iOS 3)More boilerplate; concurrency rules must be followed carefully
SQLite via a library (for example GRDB) or directlyData-heavy apps, complex SQL, shared schema logic with Android or a backend, full control over queriesAny supported versionThird-party dependency or raw C API; you own migrations and observation
Files (JSON, images, documents) in the app containerLarge media, exported documents, simple snapshotsAnyNo querying; you manage consistency and cleanup
UserDefaultsSmall preferences and flagsAnyNot for secrets, large data or anything you query
KeychainTokens, passwords, keysAnySmall items only; design for access control and device migration

Core Data

Apple’s Core Data documentation lists persistence, undo and redo, background data tasks, view synchronisation, and versioning and migration, including lightweight, staged and manual migrations. It also mirrors stores to CloudKit and supports sharing between iCloud users. If you need iOS 16 support or advanced migration paths, Core Data remains a sound default, and an app can adopt SwiftData later for new screens because the two can share a store.

SQLite and libraries on top of it

Both SwiftData and Core Data typically store data in SQLite underneath. Going direct, or via a well-maintained Swift library, makes sense when you need SQL you can read, test and share across platforms. The SQLite project’s own guidance on when to use SQLite describes on-device storage and application file formats as its strongest fit, and notes its main limits: one writer at a time per database and poor behaviour over network filesystems. Neither limit usually matters inside a single iOS app.

Files, UserDefaults and the Keychain

Store images, audio and PDFs as files and keep only their paths and metadata in the database; large binary blobs make fetches and migrations slower. Apple describes Keychain services as the way to securely store small chunks of data such as passwords, keys and certificates in an encrypted database. Authentication tokens belong there, not in SwiftData, Core Data or UserDefaults.

First decide where the truth lives

Before comparing frameworks, answer one question for each type of data: is the server or the device the source of truth? The answer changes the design far more than the choice of SwiftData versus Core Data.

Pattern 1: a local cache of server data

If your backend owns the data (product catalogues, bookings, account details), the app stores a copy to make screens fast and to work briefly offline. Apple’s sample Maintaining a local copy of server data shows this pattern with SwiftData: the server is the source of truth, the app refreshes periodically, and a unique attribute (@Attribute(.unique) on a stable server identifier) means inserting a record with an existing code updates it rather than creating a duplicate. This is the simplest and most common case. Conflicts are rare because the device does not edit the data, or sends edits to the server and waits for confirmation.

Pattern 2: user-created content synced through iCloud

If the data belongs to the user (journals, notes, personal records) and you have no backend of your own, iCloud sync via SwiftData or Core Data’s CloudKit integration can be attractive. It costs you no servers, but it ties the data to the user’s Apple ID, works only on Apple platforms and gives you limited visibility into sync problems.

Pattern 3: offline-first with your own backend

If users edit data offline and the data must also reach a web dashboard, Android app or other users, you need your own sync protocol: change tracking, a queue of pending writes, conflict rules and server-side validation. The local framework stores the data; the sync logic is yours to design and test. This is the most expensive pattern, and it should be chosen deliberately, not drifted into.

For example, a field-inspection app used in basements with poor signal is a strong candidate for Pattern 3, while a restaurant-booking app usually needs only Pattern 1. Realistic network conditions also affect backend load; our article on performance testing for mobile backends covers how to model them.

How to decide: a practical decision guide

Use the questions below in order. The first one that produces a firm answer usually settles the framework.

  1. What is your minimum iOS version? If you must support iOS 16 or earlier, choose Core Data or SQLite. Check your analytics or your target market before deciding; do not guess.
  2. Is the UI built in SwiftUI? SwiftData’s main advantage is tight SwiftUI integration. In a UIKit app, its benefit is smaller and Core Data’s mature tooling is often the better fit.
  3. Do you need iCloud sync without a backend? SwiftData and Core Data both support this. Check the schema rules below before committing.
  4. Do you need complex queries, aggregates or shared schema logic with other platforms? SQLite with a library gives you SQL you can share and test directly.
  5. How much data, and how is it written? Thousands of records with occasional edits suit any option. Large imports, frequent background writes or very large datasets call for a prototype under realistic volume before you decide.
  6. How much framework risk can you accept? If the app’s core value is its data (for example a health or finance record), favour the more mature option or isolate persistence so it can be swapped.
Scenario (illustrative)Reasonable choiceWhy
New SwiftUI consumer app, iOS 17+, data cached from your APISwiftDataFast to build; Apple documents the caching pattern
Personal journaling app, no backend, iPhone and MacSwiftData or Core Data with CloudKitiCloud sync with no servers; design the schema for CloudKit from day one
Enterprise app that must support iOS 16 devicesCore DataOS support and mature migration options
Offline-first field app with Android and web clientsSQLite library or Core Data, plus a custom sync layerControl over change tracking, queries and conflict handling
Fitness app storing workouts and large mediaSwiftData or Core Data for records; files for mediaKeeps the database small and queries fast

On the last row, data design and engagement design go together: what you store locally determines how quickly progress screens load, which matters for retention. See designing fitness and wellness apps that keep users engaged.

iCloud sync and schema migration: the constraints to design for

Sync and migration are where storage decisions most often go wrong, because their rules apply long after the first release.

CloudKit schema rules

Apple’s guide to syncing SwiftData model data across devices sets out the limitations clearly:

  • Unique constraints are not enforced. Sync happens concurrently, so CloudKit cannot guarantee the .unique attribute option. Your code must tolerate and clean up duplicates.
  • All relationships must be optional, because iCloud does not guarantee atomic processing of relationship changes, and the deny delete rule is not supported.
  • Production schemas are additive only. After you promote a CloudKit schema to production, you cannot delete model types or change existing attributes.
  • Capabilities and accounts. Sync needs the iCloud and Background Modes capabilities, and configuring iCloud requires an Apple Developer account with admin permissions.

This means the caching pattern above, which relies on a unique attribute to update records, does not carry over directly to a CloudKit-synced store. Decide whether you need iCloud sync before you design the model, not after.

Migration discipline

SwiftData supports versioned schemas and migration plans; Core Data offers lightweight, staged and manual migrations. Whatever you choose:

  • Version the schema from the first release, even if version 1 is the only one.
  • Keep a test that installs every shipped schema version, adds realistic data and upgrades to the current version.
  • Prefer additive changes (new optional properties, new models) and avoid renaming without explicit mapping.
  • Never ship a migration that has only been tested on an empty store.

Implementation plan for the first release

A short spike before the main build answers most of the uncertainty. For a typical new app, we plan it as follows.

  1. List data types and owners. For each entity, record the source of truth, expected volume, sensitivity and whether it is edited offline.
  2. Assign each type to a store. Structured records to the model store, secrets to the Keychain, media to files, preferences to UserDefaults.
  3. Build a spike (three to five days is often enough). Implement the hardest screen’s query, a background import of realistic volume, one schema migration and, if needed, iCloud sync between two devices.
  4. Put persistence behind a repository layer. Views and view models call protocols such as WorkoutRepository, not the framework directly. SwiftUI’s @Query is convenient, but limit it to simple lists if you want the option to change stores.
  5. Keep heavy work off the main thread. Imports and large saves should run in a background context or actor so scrolling stays smooth.
  6. Protect sensitive data. Use data protection classes for files, store tokens in the Keychain and decide what must be excluded from backups.
  7. Instrument. Log store load failures, migration errors and sync errors to your crash and analytics tools, without logging personal data.
  8. Test on real devices with real volumes. Simulators hide performance and sync problems.

Team skills to look for

Whoever builds this should be able to explain the threading rules of the chosen framework, write a migration test and describe how they would detect and repair duplicate records. If you are evaluating engineers, ask them to walk through a past migration that went wrong; the answer reveals more than a coding test.

Risks, costs and a pre-build checklist

The main risks

  • Framework maturity. With SwiftData in its first year, behaviour can change between OS versions. Mitigate with a repository layer, automated tests across the OS versions you support and a review after each WWDC.
  • Data loss on update. A failed migration can make the app unusable or force a reset. Mitigate with migration tests and a recovery path, for example re-downloading server-owned data.
  • Sync surprises. Duplicates, missing relationships and slow initial sync are common with iCloud. Design for them and test with two devices and poor networks.
  • Performance drift. Queries that are fast with 100 records can be slow with 50,000. Seed test devices with realistic volumes.
  • Security gaps. Tokens in UserDefaults or unencrypted exports are common audit findings.

Where the cost goes

Framework choice rarely drives cost on its own. The expensive parts are offline editing with conflict resolution, sync with your own backend, migration testing across versions and data protection for sensitive records. A cache-only app is far cheaper than an offline-first app with the same screens, so be explicit about which one you are buying.

Checklist before the build starts

  • Minimum iOS version confirmed from data, not assumed.
  • Source of truth documented for every entity.
  • Store assigned per data type (model store, Keychain, files, UserDefaults).
  • Decision on iCloud sync made before the schema is designed.
  • Spike completed: hardest query, background import, one migration, sync if needed.
  • Repository layer agreed so the framework is not referenced from every view.
  • Migration test harness in the CI pipeline.
  • Sensitive data mapped to the Keychain or protected files.
  • Logging for store, migration and sync errors without personal data.

Frequently asked questions

Is SwiftData ready for production apps?

Many teams are shipping it, and it builds on Core Data’s engine. Its programming model is new, though, so we recommend it for iOS 17+ SwiftUI apps where a spike has confirmed your hardest queries, migrations and sync behave well, and with persistence behind a repository layer so it can be replaced if needed.

Can we start with Core Data and move to SwiftData later?

Yes. Apple documents adopting SwiftData in an existing Core Data app, and the two can work with the same store. Many teams keep Core Data for existing features and use SwiftData for new SwiftUI screens once their minimum OS is iOS 17.

Do we need iCloud sync if we have our own backend?

Usually not. If your backend owns the data, cache it locally and sync with your API. iCloud sync suits personal data on Apple devices without a backend; combining both creates two sync systems that can disagree.

Where should we store login tokens?

In the Keychain. Apple’s Keychain services are designed for small secrets such as passwords and keys. Do not store tokens in UserDefaults, SwiftData or Core Data.

How long does a storage spike take?

For a typical app, a few days covers the hardest query, a realistic import, one migration and a two-device sync test. Treat that as an illustrative estimate; complex offline-first apps need longer.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Apple Developer: SwiftData framework documentation — accessed 9 November 2026. SwiftData’s purpose, its basis in Core Data, @Model, ModelContext, @Query, iCloud sync and the iOS 17 minimum.
  2. Apple Developer: Core Data framework documentation — accessed 9 November 2026. Core Data’s persistence, undo, background tasks, CloudKit mirroring and lightweight, staged and manual migrations.
  3. Apple Developer: Syncing model data across a person’s devices — accessed 9 November 2026. CloudKit schema limits: unenforced unique constraints, optional relationships, no deny delete rule, additive-only production schemas.
  4. Apple Developer: Maintaining a local copy of server data (sample) — accessed 9 November 2026. Server-as-source-of-truth caching pattern with a unique attribute for upserts.
  5. SQLite: Appropriate Uses For SQLite — accessed 9 November 2026. SQLite’s fit for on-device storage and its single-writer and network filesystem limits.
  6. Apple Developer: Keychain services — accessed 9 November 2026. Keychain as the encrypted store for small secrets such as passwords, keys and certificates.

Planning storage and sync for a new iOS app?

Tell us about your data, users and minimum iOS version, and we will help you scope a storage spike and the team to deliver it.