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
Swift 5
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { webView.evaluateJavaScript("your javascript string") { (value, error) in if let errorMessage = (error! as NSError).userInfo["WKJavaScriptExceptionMessage"] as? String { print(errorMessage) } } }