How to inject JavaScript code into a WKWebView in Swift?

To inject JavaScript code into a WKWebView in Swift, you can use the evaluateJavaScript(_:completionHandler:) method provided by WKWebView. Here is an example code snippet that loads a web page and then injects a JavaScript code snippet that changes the background color of the document: In this example, the webView(_:didFinish:) method is called when the web … Read more

WKWebView NSCoding support was broken in previous versions

WebKit was introduced in iOS 8 but was released with an error which resulted in a runtime crash if the configuration was done using Interface Builder. So in Xcode 9 if your project configuration has minimum OS support less than 11.0 and you try to add WebKit using interface builder Xcode shows an error. This … Read more