Swift & SwiftUI
Swift and SwiftUI explained with working code examples: concurrency, data flow, layout and common compiler errors.
-

Fix: Timer.TimerPublisher Won’t Restart After connect().cancel()
Timer.TimerPublisher keeps firing after you cancel the sink, and connect() won’t restart it. Fix the connection lifetime with AnyCancellable and autoconnect.
-

SwiftUI Timer: How to Repeat Without RunLoop Bugs
Replace Timer and RunLoop with TimelineView, Task.sleep, AsyncTimerSequence or Timer.publish — and stop timers that keep firing after a view disappears.
-

Fix: tabBarMinimizeBehavior(.onScrollDown) Not Expanding on Scroll Up in SwiftUI
Learn why SwiftUI’s native tabBarMinimizeBehavior doesn’t expand on scroll reversal and how to build a responsive custom tab bar using onScrollGeometryChange.
-

Fix: Sheet presentationSizing Fitted Height Broken by NavigationStack in SwiftUI
Learn why presentationSizing(.fitted) fails with NavigationStack in SwiftUI sheets and the overlay workaround to restore proper height on iPadOS 18+.
-

Fix: TextField Scroll Delay Above Keyboard in SwiftUI List
Eliminate the 0.5-second delay when a TextField in a SwiftUI List scrolls above the keyboard. Two proven fixes with code.
-

Fix: Cannot Assign CGRect Property to Variable in Switch Statement
Learn why assigning CGRect.width to a variable fails and how KeyPath solves dynamic axis selection cleanly.
-

Fix: SwiftUI Child View Changes Not Propagating to Parent State Array
Learn why SwiftUI child view modifications to struct properties don’t update the parent array and how to fix it using @Binding and…
-

Fix: LazyVStack Scroll Position Lost When Prepending Items in iOS 27
Fix LazyVStack scrollTo failures in iOS 27: open at bottom, prepend items without jumping. Use scrollPosition, scrollTargetLayout, and onScrollPhaseChange.

