home.social

#swiftdata — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #swiftdata, aggregated by home.social.

fetched live
  1. Part 3 of my SwiftData and iCloud sync series is up. It covers what you only see once the app runs on someone else's device.

    Your empty state is now a loading state. A second device opens empty and fills in, so the view you wrote for new users asks people to add data they already have.

    Your widget does not hear about remote changes. Your app merges them and calls reloadTimelines, or nothing happens.

    And the CloudKit schema only ever grows.

    thorsten-stark.de/posts/2026-0

    #SwiftData #CloudKit

  2. If your app seeds initial data and that data syncs over iCloud, be aware of duplicates.

    When the iPhone seeds 12 subjects on first launch and the iPad later on first start finds an empty store, it seeds its own 12. iCloud sync then merges both sets and the user ends up with 24. Nothing errors, and CloudKit rules out @ Attribute(.unique).

    Use fixed identifiers for seeded objects instead of fresh UUIDs. Cheap before release, painful after.

    thorsten-stark.de/posts/2026-0

    #SwiftData #CloudKit #iOSDev

  3. Worth remembering: turn on iCloud sync and your SwiftData models have to follow CloudKit's rules. Some of what SwiftData gives you is now off the table.

    No @ Attribute(.unique) and no #Unique; leave one in and the container fails to initialize. Every property optional or defaulted. Every relationship optional and with an inverse.

    I wrote up what I had to change in my apps: thorsten-stark.de/posts/2026-0

    #SwiftData #CloudKit #iOSDev

  4. Just submitted a #SwiftData suggestion, e.g. so we can require save validation like when we want no whitespace and not empty:

    @Attribute(minLength: 1, regex: /.*\S.*/)
    var title: String

    I.e. basically the code version of what we used to be able to do in the Core Data model editor.

    FB24052006: Enhancement Request: Extend @Attribute macro to support property-level validation constraints (non-whitespace, string length, ranges)

    github.com/feedback-assistant/

  5. Just got in from the coding shed. Satisfied - got public and private CloudKit syncing code working in a new app. My brain is starting to cool down now into Sunday evening.
    #indiedev #swiftui #cloudkit #swiftdata

  6. Just got in from the coding shed. Satisfied - got public and private CloudKit syncing code working in a new app. My brain is starting to cool down now into Sunday evening.
    #indiedev #swiftui #cloudkit #swiftdata

  7. Had a productive day today on the coding front. I redid some of my @CloudKit sync logic (amazing how much more sense things make when you draw it out on paper 🤔) and it looks like it’s working now.
    #indiedev #cloudkit #swiftdata #swiftui

  8. Had a productive day today on the coding front. I redid some of my @CloudKit sync logic (amazing how much more sense things make when you draw it out on paper 🤔) and it looks like it’s working now.
    #indiedev #cloudkit #swiftdata #swiftui

  9. More on quality of life improvements in your projects

    If you are working on anything more than a trivial app, taking the time to get working previews can be so helpful.

    It can be tricky to get preview environments working with things like #SwiftData or complex environments but I find it's almost always worth the time.

    I'm going to offer consulting services just creating working previews for people or getting their apps submitted to App Store Connect.

    #iOSDev #macOSDev #SwiftUI

  10. More on quality of life improvements in your projects

    If you are working on anything more than a trivial app, taking the time to get working previews can be so helpful.

    It can be tricky to get preview environments working with things like #SwiftData or complex environments but I find it's almost always worth the time.

    I'm going to offer consulting services just creating working previews for people or getting their apps submitted to App Store Connect.

    #iOSDev #macOSDev #SwiftUI

  11. Spotted a silent performance gotcha in SwiftData: FetchDescriptor.propertiesToFetch is completely ignored!

    Even if you configure a query to pull a single column to save memory, SwiftData silently overrides it and runs a full SELECT * payload. It seems to be a framework translation gap trying to force a full PersistentModel return type over legacy Core Data constraints.

    Logged the feedback report here:
    🔗 github.com/feedback-assistant/

    #SwiftData #SwiftUI #iOSDev

  12. Noticed it was fixed in beta 3 so the template now works on iOS because they added:

    #if os(macOS)
    ...
    #else
    NavigationStack {
    content()
    }
    #endif

    My report didnt even have any similar reports so probably wasn't even looked at.

    I submitted new feedback FB23618678 about the @.Query animation mistake #SwiftData

    github.com/feedback-assistant/

  13. Moving from Core Data to SwiftData? Don't clean up your model on the first pass.

    A practical "room by room" migration strategy showing why matching the legacy SQLite schema exactly is critical. Skip this and your users get a fatal error on launch.

    🔗: emredegirmenci.substack.com/p/ by Emre Degirmenci (@aemre)

    #SwiftData #CoreData #iOSDev

  14. Anyone had any luck with the new #SwiftData HistoryObserver?

    Following the sample code from What's New in SwiftData. Xcode doesn't know what @.SyncActor is among other issues.

    Is this not in yet? I can't find anything in the scant docs on this newer stuff.

    Not sure I want OS 27 only at this point but I would like to see how this works before deciding.

    developer.apple.com/videos/pla

    #iOSDev #macOSDev

  15. Anyone had any luck with the new #SwiftData HistoryObserver?

    Following the sample code from What's New in SwiftData. Xcode doesn't know what @.SyncActor is among other issues.

    Is this not in yet? I can't find anything in the scant docs on this newer stuff.

    Not sure I want OS 27 only at this point but I would like to see how this works before deciding.

    developer.apple.com/videos/pla

    #iOSDev #macOSDev

  16. #SiriAI is the real deal. Sure its still got some rough edges, but beta 2 sets a great baseline. I particularly love the “sources” buttons in the Siri.app thread transcripts, which contain URLs directly into source app data. #AppIntents ftw

    I do wonder where the intersection of this and #SwiftData will be. Developers are already declaring their models, so lets DRY, please? What will the best practices be?

  17. If you're using #SwiftData and need undo support with manually created containers (i.e. you have a schema/migrations) you need to add the undoManager manually after creating the container.

    container.mainContext.undoManger = UndoManager

    Then you need to use it to undo model changes with

    container.undoManager?.undo()

    just calling undoManager?.undo will not revert model changes.

    Ask me how I know?

    related: I fixed an undo bug today.

    #iOSDev #macOSDev

  18. If you're using #SwiftData and need undo support with manually created containers (i.e. you have a schema/migrations) you need to add the undoManager manually after creating the container.

    container.mainContext.undoManger = UndoManager

    Then you need to use it to undo model changes with

    container.undoManager?.undo()

    just calling undoManager?.undo will not revert model changes.

    Ask me how I know?

    related: I fixed an undo bug today.

    #iOSDev #macOSDev

  19. I'm looking for a sample #SwiftUI project using the AppIntents framework to read/write data from/to #CoreData (and/or #swiftdata

    Do I use the AppDependencyManager thing? A database singleton?

    Do I use the main thread? A background thread/context?

    Any idea? Thank you!

    #iosdev

  20. I'm looking for a sample #SwiftUI project using the AppIntents framework to read/write data from/to #CoreData (and/or #swiftdata

    Do I use the AppDependencyManager thing? A database singleton?

    Do I use the main thread? A background thread/context?

    Any idea? Thank you!

    #iosdev

  21. What's new in Swift Data? This WWDC session will dive into...

    - Save custom data types conforming Codable
    - Observe store changes at data store using ModelResultsObserver and HistoryObserver
    - Query now supports sections.

    developer.apple.com/la/videos/

    #apple #swiftlang #swiftdata #wwdc

  22. What's new in Swift Data? This WWDC session will dive into...

    - Save custom data types conforming Codable
    - Observe store changes at data store using ModelResultsObserver and HistoryObserver
    - Query now supports sections.

    developer.apple.com/la/videos/

    #apple #swiftlang #swiftdata #wwdc

  23. Thank you to the #SwiftData team for their Group Lab! You all rock and I always learn so much. #wwdc26

  24. Thank you to the #SwiftData team for their Group Lab! You all rock and I always learn so much. #wwdc26

  25. #SwiftData and the improvements to it this year at #WWDC are great.

    Except if you use CloudKit and your queries are updated repeatedly regardless of if the data has changes.

    You won’t notice it for simple views but anything complex will re-render, be slow and possibly flash, etc.

    I’ve seen Apple engineers suggest that can happen please provide feedback. I have.

    This is why the yearly update cycle sucks. Maybe next time.

    So back to manual fetches and a view model (or ??)

    Sigh.

  26. #SwiftData and the improvements to it this year at #WWDC are great.

    Except if you use CloudKit and your queries are updated repeatedly regardless of if the data has changes.

    You won’t notice it for simple views but anything complex will re-render, be slow and possibly flash, etc.

    I’ve seen Apple engineers suggest that can happen please provide feedback. I have.

    This is why the yearly update cycle sucks. Maybe next time.

    So back to manual fetches and a view model (or ??)

    Sigh.

  27. Something I didn’t see someone mention during the #WWDC26 is that #SwiftData now supports dynamic compound predicates!

    Haven’t tested it, but looks like a great extension to the already existing static compound predicates.

    developer.apple.com/forums/thr

  28. Some of the new features in SwiftData are incredible. However we still don’t have a way to add collaboration to apps using #SwiftData feels like something we are never going to get ☹️

  29. Some of the new features in SwiftData are incredible. However we still don’t have a way to add collaboration to apps using #SwiftData feels like something we are never going to get ☹️

  30. Why I chose SwiftData + CloudKit for Roost — even though
    they're still rough at the edges:

    ✅ Apple ID-only auth (no third-party backend)
    ✅ Private database = Apple can't read user data
    ✅ Zero server cost for me as an indie

    The trade-off: CloudKit's relationship rules took me 2 hours
    to debug today (turns out both sides of a one-to-many need
    to be declared, not just the inverse side).
    But for a local-first app, the privacy trade-off is worth it.

    #SwiftData #CloudKit #indiedev #iOSDev

  31. Ensembles 3 is here. 🎉

    A local-first sync framework for Core Data & SwiftData. No server, no cloud bill, no lock-in — your data syncs through services your users already have (iCloud, Dropbox, WebDAV…), or peer-to-peer.

    I built it before the world moved to the cloud. It was almost end-of-life, but, lately, the world's been coming back around to local-first.

    It's free to use with CloudKit and SwiftData/CoreData.

    ensembles.io

    #localfirst #SwiftLang #CoreData #SwiftData

  32. Ensembles 3 is here. 🎉

    A local-first sync framework for Core Data & SwiftData. No server, no cloud bill, no lock-in — your data syncs through services your users already have (iCloud, Dropbox, WebDAV…), or peer-to-peer.

    I built it before the world moved to the cloud. It was almost end-of-life, but, lately, the world's been coming back around to local-first.

    It's free to use with CloudKit and SwiftData/CoreData.

    ensembles.io

    #localfirst #SwiftLang #CoreData #SwiftData

  33. New to SwiftData? This tutorial covers everything from @ Model setup to CRUD operations, advanced predicates, and relational data management. A great comparison with SQLite and Realm that highlights SwiftData's tight SwiftUI integration.

    🔗: bugfender.com/blog/swift-data/ by Aleix Ventayol

    #SwiftData #iOSDev #SwiftUI