Malcolm Hall

@malhal
131 Followers
141 Following
322 Posts
iPhone developer since 2007, Windows Mobile before. Enjoy travelling, playing guitar, home brewing. Academic researcher with a Ph.D. in Computer Science from the University of Glasgow. #SwiftUI #SwiftData
Bloghttp://www.malcolmhall.com

Gemini's thoughts 2/2:

"While it is creative to try and sneak observation tracking into a @.Model's @.Transient property from a View's init, it fundamentally fights how SwiftUI and SwiftData are designed to work.
Let's do a quick code review to break down exactly what goes wrong here, why withContinuousObservation is misapplied, and how to fix it cleanly."

Gemini's thoughts 1/2:

"To give it to you straight: No, this code is not valid, and it contains several critical architectural anti-patterns that will cause memory leaks, infinite rendering loops, and missed data updates."

There's a shocker near the end of the #wwdc26 session: Code-along: Add persistence with SwiftData (see screenshot)

It's a work around for not being able to use didSet in @.Model class. Since the view puts the observation token inside the activity model it means the activity can only be monitored in one View at a time. So it should really be activity.itemViewToken and need to be sure no ActivityItemView exists for the same activity. But likely causes a retain cycle and a memory leak.

#Swiftdata

Submitted my first Xcode 27 feedback:

FB22995468: SwiftUI Multiplatform SwiftData template broken in Xcode 27 beta 1

https://github.com/feedback-assistant/reports/issues/804

FB22995468 : SwiftUI Multiplatform SwiftData template broken in Xcode 27 beta 1 · Issue #804 · feedback-assistant/reports

Submission Date 2026-06-09 Status Open Area Xcode Operating System Version macOS 27 Type Incorrect/Unexpected Behavior Description The new template has a major issue, when launched on iOS there is ...

GitHub

Check this dumb code in the new app template:

fileprivate struct NavigationViewWrapper<Content: View>: View {
let content: () -> Content

var body: some View {
#if os(macOS)
NavigationSplitView {
content()
} detail: {
Text("Select an item")
}
#else
content()
#endif
}
}

Means it's unusable on iOS because the toolbar doesn't appear since there is no navigation container so you just get blank white screen.

#swiftUI #wwdc26

Finally single @.State object init!!!

"Build your project in Xcode 27 or later so that the @State attribute uses the State() macro to create a state value in an App, Scene, or View. This change only initializes and stores your property once when it’s a class."
https://developer.apple.com/documentation/updates/swiftui

But please don't put async funcs in classes, you will corrupt the vars if you await then try to set one, because of re-entrancy.

#SwiftUI #wwdc26

SwiftUI updates | Apple Developer Documentation

Learn about important changes to SwiftUI.

Apple Developer Documentation

Swift Blog Carnival
https://swiftcarnival.github.io/

May: Where did #SwiftUI leave you hanging?

Swift Blog Carnival

A monthly community blogging event for Swift developers. Volunteer to host, pick a topic, and bring the community together.

Ah think I might have fallen for the undocumented mistake that sheet's always need a child View. Which also fixes the stale state on first present bug.

Submitted FB22770051: Crash when dismissing confirmationDialog via outside tap when presented from a sheet ToolbarItem

https://github.com/feedback-assistant/reports/issues/800

FB22770051: Crash when dismissing confirmationDialog via outside tap when presented from a sheet ToolbarItem · Issue #800 · feedback-assistant/reports

Submission Date 2025-05-13 Status Open Area SwiftUI Operating System Version iOS 26.5 Type Incorrect/Unexpected Behavior Description Description: A critical crash occurs when a confirmationDialog i...

GitHub

It's surprising to me that this crash, triggered by dismissing a confirmation dialog from a sheet's toolbar button, still hasn't been fixed in iOS 26.5 despite being present since iOS 26.

Seems like a nested presentation collision.

https://www.reddit.com/r/SwiftUI/comments/1p5jb36/are_confirmation_dialogs_broken_in_ios_26/

#swiftui