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 w
Starting from iOS7, you can use native Javascript bridge. Something as simple as following
#import
JSContext *ctx = [webview valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
ctx[@"console"][@"log"] = ^(JSValue * msg) {
NSLog(@"JavaScript %@ log message: %@", [JSContext currentContext], msg);
};