NewsDeveloper Tools

SwiftUI WWDC 2026: AsyncImage Caching and @State Fixed

SwiftUI code on a dark Apple developer screen showing new WWDC 2026 features including AsyncImage caching and reorderable containers
SwiftUI at WWDC 2026: AsyncImage caching, lazy @State, and reorderable containers

AsyncImage has shipped without a built-in cache since SwiftUI launched in 2019. For seven years, every image-heavy iOS or macOS app needed a third-party library — Kingfisher, SDWebImage, or a hand-rolled URLCache wrapper. At WWDC 2026, Apple fixed it. They barely mentioned it in the keynote. That is the story of this year’s SwiftUI update: real fixes to real developer frustrations, shipped quietly while Liquid Glass took the stage.

AsyncImage Finally Caches Images

Starting with iOS 27 and Xcode 27, AsyncImage respects HTTP cache headers automatically. If your server sends a Cache-Control or ETag header, SwiftUI honors it. No code changes required for the default case.

For apps that need more control — a fixed 200 MB disk cache regardless of server headers — you can now pass a custom URLSession:

let config = URLSessionConfiguration.default
config.urlCache = URLCache(memoryCapacity: 50_000_000, diskCapacity: 200_000_000)
let session = URLSession(configuration: config)

AsyncImage(url: imageURL, urlSession: session) { image in
    image.resizable().scaledToFit()
} placeholder: {
    ProgressView()
}

One thing to audit before upgrading: if your app depends on always-fresh image fetches — live camera previews, real-time dashboards — make sure your server sends cache-busting headers. The default caching behavior will otherwise serve stale content.

Third-party caching libraries are not going away immediately. They offer additional features like prefetching, animated image support, and memory pressure handling. But for the majority of apps that just want remote images to stop re-downloading every scroll, the dependency is now optional.

@State Lazy Init: The Silent Bug Killer

This one has been causing subtle, hard-to-reproduce bugs for years. When a parent view reinitializes — which happens more than you would expect in SwiftUI — @Observable classes stored in @State could be recreated silently. State resets, unexpected network calls, and animation glitches would appear without a clear cause.

At WWDC 2026, Apple converted @State from a Dynamic Property to a macro. @Observable classes stored in @State now initialize exactly once per view lifetime. If the parent reinitializes, the stored object survives.

The important detail: this change is backported to iOS 17 and macOS 14. You do not need to bump your deployment target to benefit from it. Read the full breakdown on Swift with Majid for the complete API change notes.

There is a breaking change to watch for. If you set a default value in a property declaration and then reassign it in init, Xcode 27 will throw a “variable used before being initialized” error. The fix:

// This breaks in Xcode 27
@State private var viewModel = ViewModel()
init(id: String) {
    viewModel = ViewModel(id: id) // Error: variable used before being initialized
}

// Correct pattern
@State private var viewModel: ViewModel
init(id: String) {
    _viewModel = State(initialValue: ViewModel(id: id))
}

Run a codebase search for this pattern before upgrading. In large codebases it surfaces in unexpected places.

Reorderable Containers and Swipe Actions Escape List

Before WWDC 2026, drag-to-reorder and swipe actions were essentially List features. Building either in a LazyVGrid, a custom layout, or a ScrollView meant writing gesture recognizer chains from scratch — one of SwiftUI’s most-copied Stack Overflow answers.

Two new modifiers fix this. Add .reorderable() to a ForEach and .reorderContainer() to the parent, and drag-to-reorder works in any container: List, LazyVGrid, ScrollView, custom layouts. It also arrives on watchOS for the first time. Swipe actions follow the same pattern — .swipeActions now works on any view inside a scroll container via the new .swipeActionsContainer() parent modifier. Email-style swipe interactions in a grid layout are now a few lines, not a weekend project.

The performance picture also improves passively. Nested stack layouts resize up to twice as fast in iOS 27 with no code changes required. Apps with complex nested HStack/VStack/ZStack hierarchies — common in dashboards and settings screens — will feel the difference without a rewrite. The full technical breakdown is available in the DEV Community WWDC26 SwiftUI breakdown.

Notion Is Migrating to SwiftUI. Pay Attention.

At the WWDC 2026 Platforms State of the Union, Apple did not use a small utility app to demonstrate SwiftUI’s production readiness. They used Notion.

Notion — one of the most widely used productivity apps on macOS and one of the most criticized for its Electron-based sluggishness — is migrating its UI to SwiftUI. Apple noted that “porting code to Swift has never been easier” with agentic coding tools, folding the AI-assisted migration story directly into the pitch.

Notion had already moved most of its iOS experience to native rendering in 2025. The WWDC announcement extends that to the full UI. For development teams still running Electron because migration felt too risky or expensive: this is a meaningful signal. The tooling exists, the framework is proven, and the performance argument has been made on one of the highest-traffic apps in the App Store.

What to Do Now

  • Audit your AsyncImage usage. The default HTTP caching is a welcome improvement, but verify your cache headers. If you serve mutable content, send Cache-Control: no-store or proper ETag headers to prevent stale displays.
  • Search for the @State init pattern. Before upgrading to Xcode 27, search for @State private var followed by assignment in init. Fix the pattern before it becomes a compile error.
  • Replace gesture-based reordering. If you have custom drag-to-reorder code built on gesture recognizers, the new .reorderable() / .reorderContainer() APIs will cut it significantly.
  • Pin your image dependency versions. Libraries like Kingfisher and SDWebImage will update to coexist with native caching. Check their changelogs before upgrading Xcode 27.

The full API reference is available in Apple’s official WWDC26 SwiftUI guide. Xcode 27 ships the new SwiftUI Specialist agent skill that can answer questions about these APIs directly in your editor — a useful companion while updating existing code.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *

    More in:News