View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • AI & Machine Learning
    • App Intents
    • Apple Intelligence
    • Games
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Open Menu Close Menu
  • Collections
  • All Videos
  • About

More Videos

  • About
  • Summary
  • SwiftData Group Lab

    Join us online for a deep dive into WWDC26 with Apple engineers and designers to ask questions, get advice, and follow the discussion about the week's biggest SwiftData announcements. Conducted in English.

    Chapters

    • 0:00:00 - Introduction
    • 0:02:53 - What's the proper way to use SwiftData with widgets and App Intents (e.g. Shortcuts)? Is there Apple sample code showing this setup?
    • 0:04:48 - How should developers approach large datasets in SwiftData?
    • 0:07:42 - What's the best practice for creating sample data? Is inserting it via the #Preview traits parameter a good idea?
    • 0:09:55 - When should a developer choose ResultsObserver over @Query? What are the tradeoffs in performance, observation granularity, and architectural control?
    • 0:13:32 - In Core Data I used NSExpression to compute sums, averages, min/max directly on the SQL store; SwiftData has no equivalent and needs data in RAM. What's your recommendation?
    • 0:15:25 - When using SwiftUI with SwiftData, what's the best way to construct the view's state and model so users can populate non-optional attributes when adding a new object?
    • 0:18:53 - For SwiftData + CloudKit: if I published an app without an App Group or versioned schema, can I introduce them later without losing data?
    • 0:21:25 - How does using an App Group to define the SwiftData local store affect the CloudKit development and production environments, and how do I safely evolve the schema when multiple apps share the store?
    • 0:23:29 - What's the best way to manage schema evolution in development and production (CloudKit) for an app already on the App Store, when running a dev build in Xcode can cause the local store to stop syncing or duplicate entries?
    • 0:25:33 - What's the most performant way to count SwiftData objects without querying them into the views?
    • 0:25:47 - In performance-sensitive parts of an app I've manually fetched models into a cached array and managed updates myself instead of @Query. How does the team think about that tradeoff?
    • 0:30:20 - For SwiftData with CloudKit, how can I ensure synchronization happens as quickly as possible? I see long lags for data appearing across platforms.
    • 0:34:24 - What's the best way to store enums (including Codable ones) with associated values in SwiftData?
    • 0:41:09 - What are best practices for using multiple model contexts — when to split work across contexts vs. keeping everything in one?
    • 0:48:49 - How do I know if I need to paginate my queries instead of fetching all records of a type?
    • 0:50:20 - Is it a good idea to combine SwiftData with a cloud backend like Firestore for sync, or is that an anti-pattern? My app uses Firestore plus a local JSON mirror today.
    • 0:55:12 - What's the proper way to know if a database migration is required, so I can show a loading screen and keep widgets/App Intents from accessing the store mid-migration?
    • 0:57:33 - What's the best way to do grouped queries (grouping results by a model property) to display data section-wise?
    • 0:58:38 - How should I handle concurrency when a @ModelActor needs to return model data, given @Model types aren't Sendable and can't cross actor boundaries?

    Resources

      • HD Video
      • SD Video
  • Search this video…
    • 0:00:00 - Introduction
    • Engineers from the SwiftData team introduce themselves and set up a session covering SwiftData with widgets and app intents, large datasets and performance, @Query versus ResultsObserver, CloudKit sync and schema evolution, migrations, enums, multiple model contexts, and concurrency.

    • 0:02:53 - What's the proper way to use SwiftData with widgets and App Intents (e.g. Shortcuts)? Is there Apple sample code showing this setup?
    • In multi-process setups (app plus widget or App Intents extension), have one process — the app — own the database and perform migration, and coordinate access. Be careful if the user fires up the widget before launching the app for a new version, since the extension shouldn't be the one driving a migration. Design so the app owns schema changes and the extension reads once they're applied.

    • 0:04:48 - How should developers approach large datasets in SwiftData?
    • First define what "large" means for your case — many rows, large blobs stored per model, or simply many models — since the approach differs. For many rows: index the properties you query so the database can fetch them quickly, and don't fetch everything at once — put limits on your fetch requests so you don't exhaust memory. For large per-model data, use the externalStorage attribute, which stores the blob in a file next to the database rather than inline. When ingesting a large dataset, insert in smaller batches using a short-lived model context you renew each batch. And when driving a @Query in SwiftUI over many rows, make sure a precise predicate expresses exactly what you need (rather than filtering again with an if in the body) and that it's covered by an index; the persistence Instrument shows how many objects are actually being fetched under the hood.

    • 0:07:42 - What's the best practice for creating sample data? Is inserting it via the #Preview traits parameter a good idea?
    • Yes — the Sample Trips app uses preview traits to seed preview data, which is a great approach. Make the sample data expressive and diverse (long names, many entries, varied cases) so your previews exercise the full range of UI states rather than a single trivial example.

    • 0:09:55 - When should a developer choose ResultsObserver over @Query? What are the tradeoffs in performance, observation granularity, and architectural control?
    • ResultsObserver is the equivalent of @Query for use outside a SwiftUI view — reach for it in a view model or other non-view context where you still want observable results. @Query is the right tool inside views. Choose based on where the code lives and how much architectural control you want over observation, rather than a raw performance difference.

    • 0:13:32 - In Core Data I used NSExpression to compute sums, averages, min/max directly on the SQL store; SwiftData has no equivalent and needs data in RAM. What's your recommendation?
    • This is a known gap — the older NSExpression surface is being succeeded by newer Swift-based expression support, and it isn't all there yet, so a feedback request with your specific use case is genuinely useful for shaping the API. In the meantime there are workarounds: you can get min or max with a fetch limit of one plus a sort descriptor. And because Core Data and SwiftData can coexist against the same data store, where SwiftData lacks an equivalent you can reach into the Core Data stack and use NSExpression there on the same underlying data.

    • 0:15:25 - When using SwiftUI with SwiftData, what's the best way to construct the view's state and model so users can populate non-optional attributes when adding a new object?
    • Distinguish non-optional view state from non-optional model properties. A common pattern is to collect the user's input in view-local state first and only construct/insert the SwiftData model once the required (non-optional) values are provided, rather than inserting a partially-initialized object. That keeps the model's non-optional invariants intact while the form is being filled in.

    • 0:18:53 - For SwiftData + CloudKit: if I published an app without an App Group or versioned schema, can I introduce them later without losing data?
    • You can add a versioned schema at any time. Moving to an App Group container is more involved: it's a different directory and entitlements can't be aligned to the old location, so you'll get a new container and must copy the existing data over into the group container, then start from there. Set up your model configuration accordingly before switching.

    • 0:21:25 - How does using an App Group to define the SwiftData local store affect the CloudKit development and production environments, and how do I safely evolve the schema when multiple apps share the store?
    • Ensure every app reading from the App Group uses the same, appropriate CloudKit entitlement, since all of them sync to that shared container on the store's behalf. With consistent entitlements and a shared versioned schema across those apps, you can evolve the schema safely; mismatched entitlements or schemas across the group cause sync problems.

    • 0:23:29 - What's the best way to manage schema evolution in development and production (CloudKit) for an app already on the App Store, when running a dev build in Xcode can cause the local store to stop syncing or duplicate entries?
    • When a development build and the shipping app write to the same shared CloudKit store while the schema evolves, you must guard against duplicates. Keep development and production schemas coordinated through versioned schemas, and be deliberate about which clients write to the shared container so an evolving dev schema doesn't corrupt or duplicate production data.

    • 0:25:33 - What's the most performant way to count SwiftData objects without querying them into the views?
    • Use fetchCount on the model context — it returns the count without materializing the objects, which is far cheaper than fetching them and counting in the view.

    • 0:25:47 - In performance-sensitive parts of an app I've manually fetched models into a cached array and managed updates myself instead of @Query. How does the team think about that tradeoff?
    • @Query does a normal fetch under the hood; the tricky part in SwiftUI is that the view cycle can fetch more often than you'd like. Manually fetching into a cached array and managing updates is a legitimate optimization for hot paths where you need tight control, as long as you handle observation yourself — it's a reasonable tradeoff, not an anti-pattern, when @Query's automatic re-fetching is costing you.

    • 0:30:20 - For SwiftData with CloudKit, how can I ensure synchronization happens as quickly as possible? I see long lags for data appearing across platforms.
    • Beyond thorough testing, use the extensive logging that the default Core Data-backed store routes through to see what sync is doing and where time goes. CloudKit sync timing isn't fully under your control, but diagnosing via those logs — and ensuring the right client drives sync — helps you understand and reduce the cross-device lag.

    • 0:34:24 - What's the best way to store enums (including Codable ones) with associated values in SwiftData?
    • As long as the associated values are Codable, you can persist the enum. New this year, you can build predicates with RawRepresentable enumerations — covered in the What's New in SwiftData talk — so enums integrate more naturally into queries as well as storage.

    • 0:41:09 - What are best practices for using multiple model contexts — when to split work across contexts vs. keeping everything in one?
    • It depends on your objective. If the work interacts with a view, that shapes the choice; but for a self-contained background work set, a separate context (e.g. via a ModelActor) is appropriate so heavy work doesn't block the main context. Keep view-driving work on the main context and isolate background batches in their own context, merging results back deliberately.

    • 0:48:49 - How do I know if I need to paginate my queries instead of fetching all records of a type?
    • Let Instruments tell you. Watch for UI hitches and check whether you're pulling in many more objects than you actually display — if so, paginate or limit the fetch. Use FetchDescriptor's fetch limits and offsets to load in pages sized to what the UI shows, rather than fetching an entire type up front.

    • 0:50:20 - Is it a good idea to combine SwiftData with a cloud backend like Firestore for sync, or is that an anti-pattern? My app uses Firestore plus a local JSON mirror today.
    • It's a valid approach, not an anti-pattern. If your data already lives in JSON files, you can implement a custom SwiftData store backed by that source — there's an example app demonstrating a custom store — letting SwiftData manage local access while your existing backend continues to handle sync.

    • 0:55:12 - What's the proper way to know if a database migration is required, so I can show a loading screen and keep widgets/App Intents from accessing the store mid-migration?
    • For a progress UI, you can compute how many migration stages exist and override the didMigrate handler for a custom migration stage, tracking which stage you're on versus how many remain — not wall-clock time, but a stage count. Combine that with having the app own migration so extensions don't touch the store while it's mid-migration.

    • 0:57:33 - What's the best way to do grouped queries (grouping results by a model property) to display data section-wise?
    • Both ResultsObserver and @Query now support sectioning: provide a key path to a persistent property and your data is grouped by it. This gives a built-in group-by experience for section-based UIs (demonstrated in the Sample Trips app) without manually bucketing results yourself.

    • 0:58:38 - How should I handle concurrency when a @ModelActor needs to return model data, given @Model types aren't Sendable and can't cross actor boundaries?
    • Model objects aren't Sendable — they're reference-based and part of the context's object graph, so they can't be passed across actor boundaries. Instead, have the ModelActor return a Sendable representation: the model's PersistentIdentifier (or a plain value/DTO) that the receiving actor uses to re-fetch the object in its own context, rather than handing over the model instance directly.

Developer Footer

  • Videos
  • WWDC26
  • SwiftData Group Lab
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • AI & Machine Learning
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    • Documentation Archive
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines