WebView Inspectorのアプリアイコン

WebView Inspector

WKWebViewをSafariから検証する方法

開発ツール iOS & macOS

現在App Storeでは配信していません

カテゴリ
開発ツール
対応デバイス
iPhone、iPad, Mac
開発者
Cihat SALİK

Enable Safari Web Inspector on a WKWebView

この手順ガイドは英語とトルコ語のみで書かれています。 英語で読む

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

概要

WebView Inspectorは、WKWebViewでURLを読み込み、それをSafariから検証するための小さなツールでした。請求書と見積書のための別のアプリ、Paidlyに置き換わり、アプリ内ブラウザはなくなりました。

同じことは、別のアプリなしでできます。自分のプロジェクトにあるWKWebViewは、このページの手順どおりに、一行のコードとMacのSafariがあれば検証できます。

WebView Inspectorについての質問

WebView Inspectorはどのデバイスで使えますか?
WebView InspectorはiPhone、iPad, Macで動きます。AppleプラットフォームのためにSwiftUIで書かれているので、システムの外観、ダイナミックタイプ、VoiceOverにそのまま対応します。
WebView Inspectorの価格はいくらですか?
WebView Inspectorは現在App Storeでは配信していません。このページは、プライバシーポリシー、利用規約、サポートのために、そしてまだアプリを使っている方のために残しています。
WebView Inspectorは誰がつくっていますか?
イスタンブールで個人開発をしているCihat SALİKが、WebView Inspectorとここにあるすべてのアプリを書いて公開しています。サポートに答えるのも、コードを書いた本人です。
WebView Inspectorについて困ったときはどうすればいいですか?
WebView Inspectorのサポートページによくある質問をまとめています。[email protected] へのメールは、開発者本人に直接届きます。

おもちゃ箱の同じ一角から

WebView Inspectorが好みに合ったなら、近くに並んでいるこちらもどうぞ。すべて同じ手でつくっています。