Icône de l'app WebView Inspector

WebView Inspector

Inspecter un WKWebView depuis Safari

Outils de développement iOS & macOS

Pas sur l'App Store actuellement

Catégorie
Outils de développement
Fonctionne sur
iPhone, iPad, Mac
Développeur
Cihat SALİK

Enable Safari Web Inspector on a WKWebView

Ce guide pas à pas n'existe qu'en anglais et en turc. Le lire en anglais

Set isInspectable to true on the web view, turn on Web Inspector on the device, then choose the page in the Develop menu of Safari on a Mac. Apps linked against the iOS 16.4 and macOS 13.3 SDKs or later need this even in debug builds, because a WKWebView is not inspectable by default.

  1. Set isInspectable in your app

    let webView = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
    
    #if DEBUG
    if #available(iOS 16.4, macOS 13.3, *) {
        webView.isInspectable = true
    }
    #endif

    The property belongs to WKWebView, not to WKWebViewConfiguration, and you set it on each view. You can change it at any point in the view's life. In Objective-C it is webView.inspectable = YES. Anyone who turns on Web Inspector can inspect a view with this setting, so keep the #if DEBUG unless release builds should be inspectable too.

  2. Turn on Web Inspector on the iPhone or iPad

    Open Settings, go to Apps, then Safari, then Advanced, and turn on Web Inspector. On iOS 17 and earlier the path is Settings, Safari, Advanced. Simulators always have it on, and a Mac app does not need this step.

  3. Show the Develop menu in Safari on the Mac

    Choose Safari, then Settings, open the Advanced pane and check Show features for web developers.

  4. Open the inspector

    Connect the device with a cable and trust the Mac if the device asks. Run your app, open the Develop menu, choose the device, simulator or your Mac, then choose the page under your app's name.

If the web view is not in the Develop menu

Check that this exact view has isInspectable set, since the setting does not carry over to other views. Then check the Web Inspector switch on the device and the trust prompt. A JSContext has the same isInspectable property, and giving it a name makes it easy to find in the menu.

Apple documentation: Enabling inspecting content in your apps · Inspecting iOS and iPadOS

Looking for the app that took over this App Store listing? See Paidly: Invoice Maker

Présentation

WebView Inspector était un petit outil pour charger une URL dans un WKWebView et l'inspecter depuis Safari. Il a été remplacé par Paidly, une app différente consacrée aux factures et aux devis, et son navigateur intégré a disparu.

Vous pouvez faire la même chose sans app séparée. N'importe quel WKWebView de votre propre projet peut être inspecté avec une seule ligne de code et Safari sur un Mac, en suivant les étapes de cette page.

Questions sur WebView Inspector

Sur quels appareils WebView Inspector fonctionne-t-il ?
WebView Inspector fonctionne sur iPhone, iPad, Mac. L'app est écrite en SwiftUI pour les plateformes Apple : elle suit l'apparence du système, le texte dynamique et VoiceOver.
Combien coûte WebView Inspector ?
WebView Inspector n'est plus sur l'App Store. Cette page reste en ligne pour sa politique de confidentialité, ses conditions et son assistance, et pour ceux qui ont encore l'app installée.
Qui développe WebView Inspector ?
Cihat SALİK, développeur indépendant à Istanbul, écrit et publie WebView Inspector comme toutes les autres apps du site. L'assistance est assurée par la personne qui a écrit le code.
Comment obtenir de l'aide pour WebView Inspector ?
La page d'assistance de WebView Inspector répond aux questions les plus courantes, et un e-mail à [email protected] arrive directement chez le développeur.

Le même coin du coffre à jouets

Si WebView Inspector vous parle, celles-ci habitent le même quartier — toutes sorties de la même paire de mains.