Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug wkwebview in iOS 16.4.1 using XCode 14.2?

  • Environment:
  1. MacOS: Monterey 12.6.1
  2. XCode: 14.2
  3. iOS: 16.4.1
  4. Safari : 16.2 (17614.3.7.1.7, 17614)
  • Question:

I want to debug my webview, and I open safari and nothing in the my device inspector.
Than I search the information, wkwebview change the default config.
Create new setting (isInspectable) about wkwebview.
And I using the XCode 14.2 don't have this property.

if (@available(iOS 16.4, *)) {
     self.wkWebView.inspectable = YES; //Property 'inspectable' not found on object of type 'WKWebView *'
}

Have any idea to debug webview without upgrade my macOS and install XCode 14.3?

like image 401
Beginnerrrrrr Avatar asked Sep 05 '25 00:09

Beginnerrrrrr


1 Answers

I also faced the same issue and this solution works for me.

if webView.responds(to: Selector(("setInspectable:"))) {
    webView.perform(Selector(("setInspectable:")), with: true)
}

After this we can debug the WKWebView in safari.

like image 91
Vishal Gupta Avatar answered Sep 07 '25 20:09

Vishal Gupta