SwiftUI용 WebView의 로딩이 끝났을 때 콜백을 받는 법을 알려줘
Asked on 06/21/2025
1 search
To receive a callback when a WebView in SwiftUI finishes loading, you can use the new Observations API available in Swift 6.2. This API allows you to create an async sequence from the current navigation event, enabling you to observe changes and handle events such as when the loading is complete.
Here's a brief overview of how you can achieve this:
-
Use the Observations API: Create an async sequence from the
currentNavigationEvent
property of your web content. This allows you to observe each change to the navigation event. -
Handle Navigation Events: Use a loop to handle each navigation event. You can update your UI or handle errors as needed when the loading is complete.
This approach is discussed in the session Meet WebKit for SwiftUI, where it explains how to react to navigation changes in your web content using the Observations API.
For more detailed information, you can refer to the session "Meet WebKit for SwiftUI" from WWDC 2025.

Meet WebKit for SwiftUI
Discover how you can use WebKit to effortlessly integrate web content into your SwiftUI apps. Learn how to load and display web content, communicate with webpages, and more.

Explore concurrency in SwiftUI
Discover how SwiftUI leverages Swift concurrency to build safe and responsive apps. Explore how SwiftUI uses the main actor by default and offloads work to other actors. Learn how to interpret concurrency annotations and manage async tasks with SwiftUI’s event loop for smooth animations and UI updates. You’ll leave knowing how to avoid data races and write code fearlessly.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.