I've posted this as a bug on Apple's Bug Report site. I thought I'd post here too and see what I can find out as to how I might fix this...
Debugging WKWebView with Xcode using Web Inspector in Safari. I'm running on MacOS Mojave Version: 10.14.3 (18D42).
After letting upgrade of Xcode run (Version 10.2 (10E125)), when I pick the proper Device option from Safari's [Develop] menu (Version 12.0.3 (14606.4.5) of Safari), the Web Inspector comes up while running the app like before, but it displays as basically blank and useless.
1- start iOS app in the Simulator that has a WKWebView that is successfully displaying a web page that has runnable JavaScript in it. (Figure 1) Here I've picked the iPhone 6 Simulator in Xcode
. (Figure 2) App running in simulator... WKWebView takes whole screen
. (Figure 3) screen after clicking [Run Db Startup Code] button (notice new info under "Test Info:")
. (Figure 4) JS code that runs when this button is clicked.
. 2-Go to Safari window and pick [Develop] menu.
3- Pick Simulator option for the device like: Simulator -- iPhone 6 -- iOS 12.2 (16E226)
4- Pick the "index.html" option (Figure 5) Picking option in Safari after app in iPhone Simulator has been started
.
5- Web Inspector comes up, but none of the page's resources are listed (including index.html) (Figure 6) Web Inspector brought up ... this is the Debugger tab. Nothing appears.
.
(Figure 7) Web Inspector, Resources tab... also blank. Clicking the Refresh button above the Network tab does nothing.
.
6 - Clicking the Web Inspector's refresh button does nothing
Resources to load, to be able to set break-points on JavaScript lines of code. to have JS code stopped on any debugger; statement to be able to step through JS code and examine current JS variable values.
As said before, the web inspector window comes up basically empty (like there is no page loaded into the WKWebView at all (even though there is and I can visually see that JS code runs when I click buttons on test interface).
Note: If I try running on actual tethered device, NO option shows up in Safari's [Developer] menu!
Enable the Develop Menu Choose Safari > Preferences, and click Advanced. At the bottom of the pane, select the “Show Develop menu in menu bar” checkbox. Choose Develop > Show Web Inspector.
Xcode is Apple's integrated development environment (IDE) for macOS, used to develop software for macOS, iOS, iPadOS, watchOS, and tvOS. It was initially released in late 2003; the latest stable release is version 13.4. 1, released on June 2, 2022, via the Mac App Store with macOS Monterey.
You'll need to go to Settings > Advanced and check the Show Debug Menu option. Then you'll see the option to open the web inspector for the Simulator right from that menu. With the Web Inspector open, you can debug inside the Simulator just like you could right in a desktop browser with DevTools.
Managed to resolve it updating the OS to 10.14.4 and correspondingly the Safari to 12.1.
Nothing worked for me... but then I found Safari Technology Preview https://developer.apple.com/safari/technology-preview/ - installing this latest version of safari did the trick for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With