SwiftData does not support public database but you can create CKContainer and CKRecord to manually persist items in the public db.

#swiftdata #swiftui

SwiftData Basics - Wesley de Groot

SwiftData is Apple's modern framework for data persistence, introduced in iOS 17. It provides a Swift-native way to model and persist data using macros and property wrappers, making it easier than ever to work with persistent data in your apps. What is SwiftData? SwiftData is a declarative framework for data modeling and management that leverages Swift macros. It replaces Core Data's complex setup with a more intu...

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.
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. https://youtu.be/GLEdeBUIVpg
InkSpot - a SwiftUI Exam Challenge & Solution

YouTube
Patrick McConnell - Fun With SwiftData and CloudKit!

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

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!

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

SwiftData Doesn’t Work Like You Think in UIKit
https://youtu.be/Qcl2HmzFgbA

#iosdev #swiftui #swiftdata