home.social

#swiftdata — Public Fediverse posts

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

  1. One of the biggest challenges with cross Apple Platform code, is that #apple hasn’t really delivered parity across with the same APIs. Trying to use #swiftUI #swiftData and Photo/Camera access on #ios #visionos and #macos with the same code base, still introduces way too many compiler directives to do “special” API calls.

  2. Solution to Exam Part I: InkSpot - Pete Davidson & Post Malone's Tattoo Tracker. A #SwiftUI app challenging students to demonstrate C.R.U.D. in #SwiftData. youtu.be/GLEdeBUIVpg

  3. If you have a #SwiftUI List/Grid and you are iterating over Model objects using id: \.self you may encounter a duplicate key in dictionary error resulting in a crash.

    Changing to id: \.id or removing the id parameter entirely should resolve this issue.

    for example:

    forEach(photo, id: \.self) *boom*

    forEach(photo) or forEach(photo, id: \.id) all good

    Tricky to debug from the error message/trace but easy fix.

    #iOSDev #macOSDev #SwiftData #coredata

  4. Today is "First-Shot Final" in #SwiftUI class, where students build two apps in 2.5 hrs, no AI & no already-created code permitted. My students will be code-interview ready! The apps? "Pete Davidson & Post Malone's Tattoo Tracker" built with #SwiftData (Pete loves this now that he's getting his ink removed), and "Admiral Grace's Cat Facts App" (URLSession & JSON parsing). Admiral Grace Hopper is one of my cats. Solutions to be posted, soon. Congrats to my students. Hire them! Hack on!

  5. Optimize your view because we're going to machine gun update it is never the right answer. None of the data is changing. Zero updates are warranted.

    #Xcode just logs some computed property changed and redraws. In a sample app I provided Apple (naively, I know) This happens with a list of models that contain nothing more than a timestamp. No computed properties.

    This is a framework problem, not something I can optimize away.

    #SwiftData #iOSDev #MacOSDev

  6. 6 months later I'm still stuck on a issue where #SwiftData queries refresh the view excessively.

    I’ve seen very few references to anything similar in online and any time an Apple engineer replies they suggest limiting the fetched objects.

    That's not always possible, nor is it a “solution.” In my app I'm rendering complex paths on a map view and the coordinates that make up the path can't be limited.

    Excessive, unnecessary redraws are visible and a UX problem.

    #iOSDev #MacOSDev

  7. Some tech stuff is painful enough to “learn” it once and just keep reusing the same code/patterns over and over for years.

    This is to say I added some new #SwiftData stuff to my app today, adding some fairly trivial schema migrations.

    It’s just too tedious to search for improvements or better ways to do things. It works, but as with many #SwiftUI things it does not leave one feeling overly confident.

    #iOSDev #MacOSDev

  8. One thing I really want out of #wwdc is better sorting for Query in #swiftData - I want to be able to sort based on two related objects so I don’t have to do in memory sorts or duplicate data.

  9. Build a Flash Card app in #SwiftUI using #SwiftData. One of two apps my students needed to build w/o AI during their hands-on 2.5 hr. in-class 2nd mid-term. Use this as a test, (pause after each question shown, complete, and compare answers), or watch it as a refresher lesson that provides a "recipe" breakdown for thinking about basic SwiftData setup w/MockData. youtu.be/pyKM3FJhQWg #CSed, #ADE, #Swift

  10. Build a Flash Card app in #SwiftUI using #SwiftData. One of two apps my students needed to build w/o AI during their hands-on 2.5 hr. in-class 2nd mid-term. Use this as a test, (pause after each question shown, complete, and compare answers), or watch it as a refresher lesson that provides a "recipe" breakdown for thinking about basic SwiftData setup w/MockData. youtu.be/pyKM3FJhQWg #CSed, #ADE, #Swift

  11. Build a Flash Card app in #SwiftUI using #SwiftData. One of two apps my students needed to build w/o AI during their hands-on 2.5 hr. in-class 2nd mid-term. Use this as a test, (pause after each question shown, complete, and compare answers), or watch it as a refresher lesson that provides a "recipe" breakdown for thinking about basic SwiftData setup w/MockData. youtu.be/pyKM3FJhQWg #CSed, #ADE, #Swift

  12. Build a Flash Card app in #SwiftUI using #SwiftData. One of two apps my students needed to build w/o AI during their hands-on 2.5 hr. in-class 2nd mid-term. Use this as a test, (pause after each question shown, complete, and compare answers), or watch it as a refresher lesson that provides a "recipe" breakdown for thinking about basic SwiftData setup w/MockData. youtu.be/pyKM3FJhQWg #CSed, #ADE, #Swift

  13. Build a Flash Card app in #SwiftUI using #SwiftData. One of two apps my students needed to build w/o AI during their hands-on 2.5 hr. in-class 2nd mid-term. Use this as a test, (pause after each question shown, complete, and compare answers), or watch it as a refresher lesson that provides a "recipe" breakdown for thinking about basic SwiftData setup w/MockData. youtu.be/pyKM3FJhQWg #CSed, #ADE, #Swift

  14. Ok, Have tested the app now up to 1100 transactions, seems to be more responsive, (not completely as good as I want it to be, but amazingly better). Wonder if I should add pagination, like I did on #visionOS #apple #swiftdata #SwiftUI

  15. I think I know the answer to this, unfortunately, but…

    I got this crash via TestFlight feedback. Despite being able to identify the line that crashed, there's no way to recover the actual error right?

    SwiftData migration crashes are such a bummer. This is probably an expected problem caused by an intermediate schema, but it might be signifiant. #SwiftData #Swift

  16. "I survived my first SwiftData migration, and all I got was this lousy–"

    Lost connection with debugger. #SwiftData

  17. I've got the schema upgrade basically working, but I think I'd better move all the blobs out of it and into the file system.

    Still, this is a good stable point to pause. I don't need to post a build of this. #SwiftData

  18. I've also been working on a Python script to pin/reset data. I'll post it in a few days, but here's a few things I've learned so far:

    To show the top level of your repo:
    git rev-parse --show-toplevel

    To get the bundle ID of your project from there:
    xcodebuild -showBuildSettings
    (Search for PRODUCT_BUNDLE_IDENTIFIER =)

    To get the simulator's container:
    xcrun simctl get_app_container booted BUNDLE_ID data

    From that directory, look in Library/Application Support. #SwiftData #Xcode

  19. Thinking about how to update my SwiftData models so I don't need to change code everywhere. (This is in addition to my typealiases earlier.)

    The rest of my code can just use notes. notesV1 can't be private because the migration needs to know about it, but it's new.

    This seems safe, and if so very little code updating will be required.

    Note: I am NOT changing the schema just to make these fields non-optional, but since I'm changing the schema anyway it seems a reasonable step. #SwiftData

  20. So this should work, right?

    enum SchemaV1 { /* includes Table */}
    typealias CurrentSchema = SchemaV1

    typealias Table = CurrentSchema.Table

    …I had weird compiler errors with it last night, but I musta screwed it up because it's working great (so far) today.

    The point is being able to update CurrentSchema to SchemaV2, etc. in the future and save fixing Table = SchemaV1.Table for all tables. #Swift #SwiftData

  21. How often does storing a calendar date (without time) as a Date in SwiftData turn out to be a mistake? #SwiftData #Swift

  22. I’ve published the first post in a new series documenting what I’m learning while building small, focused apps on iOS 26.

    This one looks at Pocket Pantry, a SwiftData-first app designed to surface architectural and data-modeling decisions early.

    iamshift.substack.com/p/pocket

    #iamshift #iOS26 #SwiftData #AppleDev #SoftwareArchitecture

  23. I’ve published the first post in a new series documenting what I’m learning while building small, focused apps on iOS 26.

    This one looks at Pocket Pantry, a SwiftData-first app designed to surface architectural and data-modeling decisions early.

    iamshift.substack.com/p/pocket

    #iamshift #iOS26 #SwiftData #AppleDev #SoftwareArchitecture

  24. I’ve published the first post in a new series documenting what I’m learning while building small, focused apps on iOS 26.

    This one looks at Pocket Pantry, a SwiftData-first app designed to surface architectural and data-modeling decisions early.

    iamshift.substack.com/p/pocket

    #iamshift #iOS26 #SwiftData #AppleDev #SoftwareArchitecture

  25. I’ve published the first post in a new series documenting what I’m learning while building small, focused apps on iOS 26.

    This one looks at Pocket Pantry, a SwiftData-first app designed to surface architectural and data-modeling decisions early.

    iamshift.substack.com/p/pocket

    #iamshift #iOS26 #SwiftData #AppleDev #SoftwareArchitecture

  26. FB21159411 #CloudKit causes excessive view updates with #SwiftData Queries

    Things are pretty bad for me to file feedback.

    App views are updated far too often regardless if data changes. (at least on MacOS)

    For simple text views you are unlikely to notice. With more complex views such as a map with the markers dancing around with each update it is a deal breaker.

    I am wondering if this is causing some sketchy app behavior in Tahoe?

    or I'm holding it wrong…

    #SwiftUI #Swift

  27. It’s kinda fun that you can go from a local app to a multi-platform client/server app using #SwiftUI and #SwiftData with very few changes to your data model and with no changes to the APIs you call

    #SwiftLang #BuildInPublic #Technology #Apple #CloudKit #Apps

  28. Офлайн-режим в мобильном приложении: зачем он нужен и как его реализовать

    Представьте: пользователь открывает ваше приложение в метро, за секунду до въезда в тоннель. Вместо ошибки «Нет соединения» он видит контент, который уже загрузил, или даже продолжает заполнять форму — потому что приложение просто отложит синхронизацию до момента, когда сеть появится. Это не магия, а продуманный офлайн-режим. В этой статье мы расскажем как реализовать его в приложении на iOS.

    habr.com/ru/companies/beget/ar

    #офлайнрежим #uiux #uiux_design #работа_в_офлайне #ios_development #ios_design #ios #swift #swiftdata

  29. Офлайн-режим в мобильном приложении: зачем он нужен и как его реализовать

    Представьте: пользователь открывает ваше приложение в метро, за секунду до въезда в тоннель. Вместо ошибки «Нет соединения» он видит контент, который уже загрузил, или даже продолжает заполнять форму — потому что приложение просто отложит синхронизацию до момента, когда сеть появится. Это не магия, а продуманный офлайн-режим. В этой статье мы расскажем как реализовать его в приложении на iOS.

    habr.com/ru/companies/beget/ar

    #офлайнрежим #uiux #uiux_design #работа_в_офлайне #ios_development #ios_design #ios #swift #swiftdata

  30. Офлайн-режим в мобильном приложении: зачем он нужен и как его реализовать

    Представьте: пользователь открывает ваше приложение в метро, за секунду до въезда в тоннель. Вместо ошибки «Нет соединения» он видит контент, который уже загрузил, или даже продолжает заполнять форму — потому что приложение просто отложит синхронизацию до момента, когда сеть появится. Это не магия, а продуманный офлайн-режим. В этой статье мы расскажем как реализовать его в приложении на iOS.

    habr.com/ru/companies/beget/ar

    #офлайнрежим #uiux #uiux_design #работа_в_офлайне #ios_development #ios_design #ios #swift #swiftdata

  31. Офлайн-режим в мобильном приложении: зачем он нужен и как его реализовать

    Представьте: пользователь открывает ваше приложение в метро, за секунду до въезда в тоннель. Вместо ошибки «Нет соединения» он видит контент, который уже загрузил, или даже продолжает заполнять форму — потому что приложение просто отложит синхронизацию до момента, когда сеть появится. Это не магия, а продуманный офлайн-режим. В этой статье мы расскажем как реализовать его в приложении на iOS.

    habr.com/ru/companies/beget/ar

    #офлайнрежим #uiux #uiux_design #работа_в_офлайне #ios_development #ios_design #ios #swift #swiftdata

  32. I am still checking, butI think that I have encountered this:

    developer.apple.com/forums/thr

    #CoreData presumably created a new CloudKit CKAsset field for an `externalStorage` property at runtime when it encountered an asset that is too large for the database. This causes automatic #SwiftData CloudKit sync to fail because that record doesn't exist in the server.

    If so, this is broken, it should create all fields it'll eventually need so that they can be properly added to the production CloudKit schema.

  33. I filed this feedback to make Enums better with SwiftData: FB19106719

    @ricketson @lucabernardi @curtclifton

    I couldn’t find anyone working in the #CoreData or #SwiftData team so I ping you. Thank you.

  34. I'm loving the new @pointfreeco SharingGRDB framework! It's so much better to work with value-type models than reference-type models.

    In the code below I'm migrating from SwiftData to SharingGRDB. First I put the creation of the Weight.Draft inside the async block below. This gave me an error because the SwiftData models are not sendable. The SharingGRDB models are so the fix was so simple :)

    #swift #swiftlang #swiftdata #sharinggrdb #structuredconcurrency

  35. I'm loving the new @pointfreeco SharingGRDB framework! It's so much better to work with value-type models than reference-type models.

    In the code below I'm migrating from SwiftData to SharingGRDB. First I put the creation of the Weight.Draft inside the async block below. This gave me an error because the SwiftData models are not sendable. The SharingGRDB models are so the fix was so simple :)

    #swift #swiftlang #swiftdata #sharinggrdb #structuredconcurrency

  36. I'm loving the new @pointfreeco SharingGRDB framework! It's so much better to work with value-type models than reference-type models.

    In the code below I'm migrating from SwiftData to SharingGRDB. First I put the creation of the Weight.Draft inside the async block below. This gave me an error because the SwiftData models are not sendable. The SharingGRDB models are so the fix was so simple :)

    #swift #swiftlang #swiftdata #sharinggrdb #structuredconcurrency

  37. I'm loving the new @pointfreeco SharingGRDB framework! It's so much better to work with value-type models than reference-type models.

    In the code below I'm migrating from SwiftData to SharingGRDB. First I put the creation of the Weight.Draft inside the async block below. This gave me an error because the SwiftData models are not sendable. The SharingGRDB models are so the fix was so simple :)

    #swift #swiftlang #swiftdata #sharinggrdb #structuredconcurrency