Search code examples
safariuiwebviewwkwebviewinspection

Safari won't see/show the web inspector of my app's WebView (WKWebView or UiWebView)


I have been working on my appliance years now, and as always using the Safari's Web Inspector. But today my Mac's Safari Inspector won't show/see anymore my App's webview, anyone have a clue about what could it be?

MacOS: 13.3.1 Processor: M1 Pro iOS: 16.4.1 App Target Minimum iOS Version: 13.0

P.S.: the MacOS safari is still able to inspect my iPhone safari, but anymore on my app.


Solution

  • After reading some articles, I found out that Apple created one attribute on the WebView protocol, so from the iOS 16.4 or newer, you need to make the web inspection available like this:

    Swift

    if #available(macOS 13.3, iOS 16.4, tvOS 16.4, *) {
        webView.isInspectable = true
    }
    

    Objective-C

    if (@available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) {
        _webView.inspectable = YES;
    }