How to debug javascript code inside a WKWebView How to debug javascript code inside a WKWebView javascript javascript

How to debug javascript code inside a WKWebView


UPDATE: 2017/09/11

Recent versions of Safari can do this. Just enable the develop menu in Safari - developer.apple.com

OLD:

You need to install the nightly build of Safari and use that. I was having the same problem with an app I'm developing. Once I installed the nightly build, I now use that and all of my WKWebViews show up in the develop menu.

Hope that's the part you were missing!


open the website or html page in your webview, then open safari. click develop, then go to simulator and you will find your website title there. once you open it you will see the javascript debugger, console and everything else you can dream of.


You can try http://jsconsole.com/

Execute :listen and it gives you a script tags to paste in your webpage.

Every console.log you have in that page will give their output to this page.

If you close jsconsole page, next time you should change script src in html code but you can listen to that script src too:

:listen XXXXX-XXXXX-XXXX-XXXXX

I hope it helps.