Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Adding SFSafariViewController code to SwiftUI app causes app to be unresponsive

Expected: Tapping cell in ProfileView navigates user to detail view

Result: Tapping cell in ProfileView causes app to freeze and become unresponsive


Steps to reproduce bug

  1. Download my project on GitHub
  2. Copy SafariViewController code in any file (e.g. bottom of OtakuSigmaApp.swift)
  3. Run app on simulator (or physical device)
  4. Tap on "Profile" in bottom tabview
  5. Click on "Total Entries" row
  6. App should be frozen and unresponsive


But if I get rid of the SafariViewController code, the app works as expected even though I never used the code within my application. Any idea as to why this unrelated behavior is happening? I need to use SFSafariViewController to handle authenticating user through a web browser but it unintentionally causes my app to freeze when a user tries to navigate to a detail view.


import SafariServices


struct SafariWebView: UIViewControllerRepresentable {
    let url: URL
    
    func makeUIViewController(context: Context) -> SFSafariViewController {
        return SFSafariViewController(url: url)
    }
    
    func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
        
    }
}

Simulator, iOS 15

Posted on May 1, 2024 5:12 PM

Reply
1 reply

Adding SFSafariViewController code to SwiftUI app causes app to be unresponsive

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.