When writing a iPhone / iPad app with a UIWebView, the console isn’t visible.
this excellent answer shows how to trap errors, but I would like to use the console.log() as well.
When writing a iPhone / iPad app with a UIWebView, the console isn’t visible.
Share
I have a solution to log, using javascript, to the apps debug console.
It’s a bit crude, but it works.
First, we define the console.log() function in javascript, which opens and immediately removes an iframe with a ios-log: url.
Now we have to catch this URL in the UIWebViewDelegate in the iOS app using the shouldStartLoadWithRequest function.