How to show the inspector within your WKWebView based desktop app?

前端 未结 4 775
庸人自扰
庸人自扰 2020-12-14 15:56

I\'m looking for a way to show the inspector for a WKWebView inside my Mac app.

With WebKit1 and WebView it was easy to show the inspector inside your Mac app, by ju

4条回答
  •  庸人自扰
    2020-12-14 16:42

    Building on Koen Bok's answer, for Swift, confer this gist. Using those files, you'll need to add the following line to your bridging header:

    #import "WKPreferences+DevExtras.h"
    

    Usage looks like

    let webView = WKWebView(frame: window.frame)
    webView.configuration.preferences.enableDevExtras();
    

提交回复
热议问题