#SwiftData

Stewart Lynch πŸ‡¨πŸ‡¦StewartLynch@iosdev.space
2025-12-07

In the final part of my Rich Notes App series, we’re adding categories, sorting, and filtering with SwiftData plus a few finishing touches to make it shine.
Watch here: youtu.be/UUvgm9-yltE
#SwiftUI #SwiftData #SwiftDevelopment @AttributedString

2025-12-07

Apple News remembers where you were, in each tab Now our app does too.

Kill the app. Relaunch. You're exactly where you left off.

Native. No third-party dependencies.

2025-12-02

Is there a way to use SwiftData in a view model, with automatic syncing of changes to the saved data, so I don't have to write shit like this because I have data in the model, but must have a `@Query` in the view to get the stored data?

#swiftui #swift #swiftdata

Stewart Lynch πŸ‡¨πŸ‡¦stewartlynch.bsky.social@bsky.brid.gy
2025-11-30

Just published a full walkthrough on building a #SwiftData backed notes app using our rich text editor from part one. We cover models, CRUD, navigation, previews, and how #AattributedString is stored as JSON in SQLite. Give it a watch. youtu.be/SL8yxBGuTuo

RichText Notes App - Attribute...

Stewart Lynch πŸ‡¨πŸ‡¦StewartLynch@iosdev.space
2025-11-30

Just published a full walkthrough on building a #SwiftData backed notes app using our rich text editor from part one. We cover models, CRUD, navigation, previews, and how #AattributedString is stored as JSON in SQLite. Give it a watch. youtu.be/SL8yxBGuTuo

2025-11-29

I have finally managed to introduce persistence (via SwiftData) to Librarius.

I started by making my data models structs – as Apple recommended – only to find out SwiftData needs classes.

It made sense, so I switched to classes, it was hell on earth. I then, thanks to the advice of a friend, had both classes and struct representations (and class models could be instantiated from structs).

This made life easier, but is it a general pattern?
#Swift #swiftUI #SwiftData
github.com/stoiandan/Librarius

Patrick McConnellpatrickmcconnell
2025-11-25

FB21159411 causes excessive view updates with 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…

2025-11-21

Initial implementation of indexing AppEntities backed by #SwiftData in spotlight - always nice to see an old library making it simpler (FetchDescriptorObserver). gist.github.com/juanarzola/131

Should be ok for just a few folders. Might need to add paging to the library to make it usable for more copious entities.

Sam Clementecountablenewt
2025-11-19

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

2025-11-16

Today's mystery:

gist.github.com/juanarzola/c5c

This code is an extension factory method on FetchDescriptor that builds a FetchDescriptor that fetches a #SwiftData model by UUID, if the model conforms to UUIDString.

Works normally. Except when running in within AppIntents (specifically in AppEntity functions that fetch the entities) on Release mode, where the uuid isn't found in the schema of models. Works on Debug.

Solution was to not use the extension, and inline the FetchDescriptor in the fetching function, using the concrete type in FetchDescriptor, instead of Model.

Why? uuid optimized out? Perhaps.

David CardeΓ±adavidcafor
2025-11-11

Trying to fetch a SwiftData model filtered by an enum (BookStatus) using or Predicate(\.status, equals:) fails every time:
Key path cannot refer to enum case / Cannot infer key path type.
Anyone found a clean way to filter enums in SwiftData?

2025-11-08

"I wonder why my sorting/grouping logic breaks when I combine model IDs from freshly-fetched #SwiftData objects with cached IDs"

because gotcha, id identity doesn't survive coding
developer.apple.com/documentatio...

but don't worry ids, have real ids in them (`id.id`).

such an intuitive API

A note of the PersistentIdentifier doc. It reads "Decoded PersistentIdentifier and identifiers created by the DefaultStore are not considered equivalent".
Snapp Mobile iOS Newsletterios_newsletter_snapp
2025-10-28

πŸ’Ύ 𝐼𝑠 π‘†π‘€π‘–π‘“π‘‘π·π‘Žπ‘‘π‘Ž π‘–π‘›π‘π‘œπ‘šπ‘π‘Žπ‘‘π‘–π‘π‘™π‘’ π‘€π‘–π‘‘β„Ž 𝑀𝑉𝑉𝑀? by Matteo Manferdini

Thinking MVVM and SwiftData don't mix? Learn how proper understanding of SwiftUI's core principles makes them perfectly compatible.

matteomanferdini.com/swiftdata

2025-10-24

Starting in under 1 hour!!! SwiftData live 3 hour workshop!!

You will learn about SwiftData architecture, relationships, testing and even CloudKit integration. I will show you the built-in SwiftData architecture, which allows you to separate your domain/business logic from views and easily make it testable.

Reserve your spot: azamsharp.teachable.com/p/swif

PS: AzamSharp Pro Members gets free access to the workshops! Use the link above to access your coupons.

#iosdev #swiftui #swiftdata

2025-10-23

AI is dumb. Still.

I have a #SwiftData property with `@Attribute(.unique, .spotlight)`. It correctly said that was invalid SwiftData, but incorrectly said it was the `.spotlight` value that was invalid. `.unique` is invalid in SwiftData.

I told it to fix it. It said I was right, and then did the exact same thing again.

Screenshot of Xcode Assistant. The prompt is "the
`.spotlight' attribute is valid in SwiftData. '.unique' is not
valid in SwiftData." The reply is:

I see, thank you for the correction. Let me fix this properly:
(Code changes elided)
l've corrected the attribute syntax to use @Attribute(.unique)
instead of @Attribute(.unique, spotlight), as you pointed out
that . spotlight is valid but . unique is not a valid SwiftData attribute
syntax. The correct SwiftData attributes are:
β€’ . unique - This is actually valid for SwiftData but was incorrectly used
in combination with . spotlight
β€’ .spotlight - This is indeed a valid SwiftData attribute for indexing
The key fix was to remove the invalid . spotlight from the
combination, leaving only β€’ unique which is a valid SwiftData attribute
for making fields unique.
7 Proposed Changes in 1 File
2025-10-23

Tomorrow I am hosting a 3 hour live hands-on workshop on SwiftData. If you use SwiftData in your apps then this workshop is for you.

You will learn about the SwiftData built-in architecture, relationships, testing and even CloudKit integration.

Reserve your spot:
azamsharp.teachable.com/p/swif

#swiftdata #iosdev #swiftui

Patrick McConnellpatrickmcconnell
2025-10-22

I will add I've only been debugging this on as that's where my app I want to use with originates

Patrick McConnellpatrickmcconnell
2025-10-22

Still debugging overzealous view redraws when using .

It appears that any time you use a query the view will be redrawn for any CoreData notifications.

For example each time a DB checkpoint is triggered the view redraws regardless if any data has changed.

Those notifications happen very often.

I've created an sample project with a static view and it refreshes constantly, even when the queried data is not used.

Unsure if 26.1 resolves anything.

2025-10-21

In my app using SwiftData, I have a `@model` class with relationship to other `@model` classes. I want a property `updated` on the parent class to be updated to `Date.now` any time any property on the parent class or child classes is modified. I cannot find a way to do this. (Using `didSet` on a child class’ attributes doesn't work because the implicit `@_PersistedProperty` macro sets the backing value via key/value encoding so the actual property's property observers don't get called.) How is this so hard?

#Swift #SwiftData

2025-10-16

Stop making working with #SwiftData complicated!!

In this workshop, I will demonstrate how you can use the SwiftData built-in architecture to write your apps. You will also learn about relationships, testing and CloudKit integration.

Register: azamsharp.teachable.com/p/swif

#SwiftUI #iOSDev

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst