Especially the #SwiftData related code. I moved everything into the background thread, so that app works smoothly, but at the cost of code readability. Until I worked daily on that, it seemed fine. Nowadays, I see a lot of things I could improve.
Especially the #SwiftData related code. I moved everything into the background thread, so that app works smoothly, but at the cost of code readability. Until I worked daily on that, it seemed fine. Nowadays, I see a lot of things I could improve.
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 :)
Adventures in mystery: if you use @Attribute(.externalStorage) in your #SwiftData app, how can you determine whether or not your data is stored in your db or externally?
Where's it stored in a Document-based app on macOS?
Fun times from exploring an (unrelated) db migration issue.
Heeeelp!
What does the following error mean, and how do I fix it? It happens, when I call `modelContext.save()` in a SwiftUI view.
"SwiftData/ModelCoders.swift:105: Fatal error: Composite Coder only supports Keyed Container”
Edit: Solved! It appears SwiftData does not support Duration properties in models. Changing it to a TimeInterval instead fixes it.
Sorry @mattiem for giving yet another example of strong behavior of ModelActor. I hope maybe you can understand why it’s behaving so strangely.
#SwiftData #ModelActor
S4E5: @mikaelacaron and @twostraws talk networking – mostly about getting computers to talk to each other, but also, just as dauntingly, about talking to other humans at conferences too.
Plus: news, Apple delays, and the trifling little matter of the major changes you’re hoping to see in #Xcode, #SwiftUI, #SwiftData and more as #WWDC25 rolls around!
https://podcasts.apple.com/gb/podcast/swift-over-coffee/id1435076502?i=1000700512953
Took a deep dive into SwiftData today! Moved operations to background threads, including the heavyweight streak recalculation. Was feeling pretty proud until I noticed the “automagic” SwiftUI animations vanished!
#SwiftData #iOSPerformance
Took a deep dive into SwiftData today! Moved operations to background threads, including the heavyweight streak recalculation. Was feeling pretty proud until I noticed the “automagic” SwiftUI animations vanished!
#SwiftData #iOSPerformance
A few months ago, I wrote a comprehensive course on SwiftData. Its just been published for Kodeco subscribers.
https://www.kodeco.com/ios/paths/continuing-swiftui/45123174-data-persistence-with-swiftdata
New Video Alert!
In this video, Mohammad Azam shows how to attach a photo to a note in your SwiftUI app using PhotosPicker!
What You’ll Learn:
Select images with PhotosPicker
Display images in your app
Fetch & manage photos with SwiftData
Best practices for handling images in SwiftUI
Refactored a gnarly bundle of code to make it correct for #Swift Concurrency.
I have a better handle on it all now but I still see a few areas it needs to improve
Passing results from async to the main thread is far too difficult requiring a lot of scaffolding to allow: self.stuff = asyncStuff
#SwiftData needs to work better with async/await. One side of the other needs to improve.
In general, it's just too much thinking, tweaking and adorning your code with magic keywords and types
My app, #PDXTransit, turns 10 years old this year this August. I wrote it when I moved to Portland back in 2015.
Well, this year for its 10th birthday, I plan to release a complete re-write using the latest technologies from Apple including an iPad-specific user experience.
Here's a sneak peek at what I've been working on the past few years with #SwiftUI, #SwiftConcurrency, and #SwiftData!!!
(and of course it comes with a re-write of its companion app for Apple Watch!)
If your use case for Swift Data is dead simple, the iCloud Sync stuff just works. I understand Swift Data still has a number of outstanding issues needing to be fixed but seems to be working just fine here.
I’m using it to sync the bookmarked transit stops that show up in the sidebar. This is turning out quite nice I suppose.
Today in Bike Index:
- Merged Bike ↔︎ User/AuthenticatedUser relationships, transactions, and frequent save() to fix the #1 crash/bug report
- Fixed GitHub "Enable auto-merge [after PR checks pass]" (gotta use jobs > build > name: Run tests with fastlane → Ruleset add checks
- Converted Xcode project groups to Folders
New in PR review:
- Added app version to Settings
- Updated README with TestFlight public beta link and incremented to version v1.1!
Phew what a day!
#iOSDev #SwiftUI #SwiftData
Just a quick #SwiftData sanity check: Mood is saved as an enum on the Entry model. There's no way to write a predicate that filters for an enum, right?
Has anyone else used #SwiftData based DocumentGroup in #SwiftUI?
It is pretty convenient compared to rolling your own storage solution. I’m able to create a custom file extension and I can keep all SwiftData properties non-optional which cannot be done with CloudKit.
However, I have had it happen a couple times where the file will refuse to open on #iPadOS after having it opened on #macOS, which is a cause for concern because I cannot afford data loss. Especially since it doesn’t appear to be possible to create backups of the file, or prevent it from being opened on more than one device, etc.
I am not sure what causes this as theres no errors in Xcode when it happens… Any ideas why that might be?
I just had to pull up that song featuring @jamesdempsey again: https://youtu.be/-dY1S-txZpI?si=Ai7nC2wLCJcuWH4R&t=3628
#CoreData #EOF #SwiftData
#SwiftData ModelActor changes aren't reflected by the Query property wrapper in #SwiftUI Views...
This issue has been raised months ago & I don't understand why it's still not fixed in iOS 18.2.
A workaround is to observe the ModelContext didSave notif: https://forums.developer.apple.com/forums/thread/759364?answerId=811927022#811927022
cc @curtclifton @ricketson @lucabernardi if you know someone at Apple working on SwiftData with SwiftUI, can you please escalate this? This is a massive hiccup.
long overdue - I used Queried in a new feature, and fixed various problems https://github.com/juanarzola/Queried/pull/9/files
- It actually does work in iOS 18 (new notification)
- it doesn't try to use the "filter" AsyncStream transform which, in my experience/crashes runs in a thread that is different from the one the notification is posted on.
- It no longer returns the query results in the async stream because they are not sendable, a requirement for AsyncStream (and Swift 6.0). #SwiftData
@helge @groue @fatbobman both async functions are isolated to the same actor (queue?) but it doesn’t mean they will be running on the same thread right? Passing non-Sendable type is ok but I thought the issue with #CoreData NSManagedObject and #SwiftData Model was that they can’t be passed between threads. Which seems to be the case with two async functions in a ModelActor.
What do you think @mattiem?
Thanks!