det.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mastodon Server des Unterhaltungsfernsehen Ehrenfeld zum dezentralen Diskurs.

Administered by:

Server stats:

2.2K
active users

#swiftdata

6 posts3 participants0 posts today

@nerdd

Answer from Perplexity:

To fix this issue, replace unsupported types with alternatives that SwiftData can handle:

For Duration: Use TimeInterval instead, as it is supported by SwiftData.

For Color.Resolved: Avoid using it directly in your models. Instead, store color-related data in a format like RGB values or another supported type.

This ensures compatibility with SwiftData's encoding requirements.

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.

Continued thread

Biggest tip I can offer when working through a migration strategy, is to work on a new git branch so you can delete a bad data store, restore the old working branch and start over.

You can create a rollback strategy as well but I found it just as easy to delete the bad data store, revert to working data and try again.

If you don't start a migration clean and it has previously failed you may find a lot of duplicate data once it does work all the way thru.

Continued thread

In my case I was migrating from a schema where a relationship was becoming many to many. I needed to gather all the current single relationships in willMigrate and then in didMigrate I had to add them to the new to many relationship.

There is no relationship between willMigrate and didMigrate so you need to do some sketchy (globals) things to pass data across contexts.

Once I'm comfortable I've gotten this all correct, I’ll do a blog post.

TIL working with #SwiftData migrations the past few days.

The documentation is non-existent. The sample code, tutorials, etc are all copying mostly trivial examples and sadly each other.

A custom migration schema has two phases each is passed a context. The first, willMigrate, will have the context for the schema you are migrating from, the second, didMigrate will have the newest context.

developer.apple.com/documentat

Apple Developer DocumentationMigrationStage.custom(fromVersion:toVersion:willMigrate:didMigrate:) | Apple Developer DocumentationThere's never been a better time to develop for Apple platforms.

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!

🎧 podcasts.apple.com/gb/podcast/

S4E5: Could you just…?
Apple PodcastsS4E5: Could you just…?Podcast Episode · Swift over Coffee · 23/03/2025 · 33m

13 Build a Gardening App with SwiftUI & SwiftData | iOS Development Tutorial | Part 13

🎯 What You’ll Learn:
✅ Creating PestCellView for structured pest display
✅ Enhancing PreviewData for realistic previews
✅ Leveraging Xcode Previews for smoother UI dev
✅ Best practices for managing preview data in SwiftData

youtu.be/M9_soMTtVlU?si=mtiNFo

youtu.be- YouTubeEnjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

🌱Build a Gardening App with SwiftUI & SwiftData | iOS Development Tutorial | Part 11

In this video, Mohammad Azam adds validation to AddNoteScreen & refactors NoteListScreen by extracting a reusable NoteCellView for a cleaner UI.

🌱 What You’ll Learn:
✅ SwiftUI form validation
✅ Refactoring for maintainability
✅ Reusable UI components
✅ Indicating which veggies have notes

🔗 Link:
youtu.be/2NJFKpvXluE?si=Qrgs27

youtu.be- YouTubeEnjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.