Safari Web Inspector stopped working on latest iOS for WebKit apps
Asked Answered
C

2

6

Using Safari Web Inspector on a WebKit based app stopped working on iOS 16.4.

This was properly working before.

More specifically, using the iOS Simulator or a real device, debugging a WebKit based app and from Safari on macOS accessing the Develop to inspect the app.

No difference at all if it is the Simulator or a real device; none seem to work, but inspecting iOS-Safari from macOS-Safari works as expected.

I already tried deleting and reinstalling the app, erasing the simulator, etc.

Coal answered 10/4, 2023 at 8:30 Comment(0)
C
10

There is a new property isInspectable on WKWebView, false by default but turning it on will enable the inspector.

This works both for iOS and macOS, no need for the old way of using KVO on macOS with developerExtrasEnabled anymore.

Available

  • iOS 16.4
  • macOS 13.3

Turning it on

wkWebView.isInspectable = true
Coal answered 10/4, 2023 at 9:5 Comment(5)
Are release builds can be inspected with it?Unroot
@Unroot Release builds can be inspected, but the inspector needs to be activated from Safari, both for iOS and macOS.Coal
This answer, thank you sir.Lyse
I am getting error Cannot find 'webView' in scopeCallison
@AbhaySingh Please share some more of your code or maybe even open a new question for it.Coal
B
1

If you don't want to update your macOS or xcode try this

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

This worked for me on XCode -> 14.2 (14C18) macOS -> 13.4 (22F66)

Ref -> https://mcmap.net/q/1771628/-how-to-debug-wkwebview-in-ios-16-4-1-using-xcode-14-2

Burundi answered 3/7, 2023 at 8:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.