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:

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

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