home.social

#swiftdata — Public Fediverse posts

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

fetched live
  1. The hardest number in Batteries At Home is the first battery in a new device.

    After two recorded changes the next one is arithmetic: dates in, interval out. A new device has no dates to do that with.

    The usual lifetime comes pre-filled from the average of every lifetime already recorded for that battery type in the house.

    A prediction indicator states its footing: rough estimate with no data, getting more accurate after one or two changes, reliable from the third on.

    #IndieDev #SwiftData

  2. The Predicate macro in SwiftData autocompletes like a Swift closure, and then reminds you that it is not one.

    It has to translate your expression into a query the store can execute, and that store only knows persisted properties. A computed var has nothing to map to, and neither does your own helper function.

    Depending on what you wrote, the compiler stops you or the fetch fails at runtime.

    Two ways out: persist the value, or fetch wider and filter in Swift.

    #SwiftData #iOSDev

  3. FB24363307: @Model.hasChanges and ModelContext.hasChanges evaluate to true when re-assigning identical values (item.title = item.title) #SwiftData

    github.com/feedback-assistant/

  4. FB24363307: @Model.hasChanges and ModelContext.hasChanges evaluate to true when re-assigning identical values (item.title = item.title) #SwiftData

    github.com/feedback-assistant/

  5. FB24363307: @Model.hasChanges and ModelContext.hasChanges evaluate to true when re-assigning identical values (item.title = item.title) #SwiftData

    github.com/feedback-assistant/

  6. 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

  7. 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

  8. 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

  9. 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/

  10. 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/

  11. 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/

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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

  19. 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

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. 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

  26. 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

  27. 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/

  28. 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/

  29. 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/

  30. 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

  31. 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

  32. 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

  33. 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

  34. 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

  35. 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

  36. 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

  37. #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?

  38. #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?

  39. #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?

  40. 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

  41. 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

  42. 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

  43. 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

  44. 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

  45. 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

  46. 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

  47. 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

  48. 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

  49. 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

  50. 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

  51. 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

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

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

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

  55. #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.

  56. #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.