WebViewBridge.Swift

swift

Like JockeyJS, written in Swift, and with support for WKWebView:

A bridge for WebView(UIWebView, WKWebView), using JavaScriptCore, handles communications between native(Swift) and js.

Example usage (call native function from JS):

// XCode
override func viewDidLoad() {

    // …

    let webView = WKWebView()
    let bridge = ZHWebViewBridge.bridge(webview)

    bridge.registerHandler("Video.Play") { (args:[AnyObject]) -> (Bool, [AnyObject]?) in
        self.player.play()
        return (true, nil)
    }

    // …
}
// JavaScript
<-- orig source: /Pods/WebViewBridge.Swift/Sources/bridge.js -->
<script src="bridge.js"></script>
<script>
    ZHBridge.Core.ready(function() {
        ZHBridge.Core.callNativeHandler('Video.Play');
    });
</script>

WebViewBridge.Swift →

Cordova WKWebView Plugin

wkwebview

Great work by the Ionic folks:

One of our awesome engineers has been working hard to bring WKWebView to Ionic apps and is working to bring the new plugin into Cordova! The new plugin will work with both Ionic V1 and Ionic V2 apps. In fact, it should work with any iOS Cordova build!

That is great news as WKWebView really is a big deal for Hybrid Development.

It’s not included in Ionic by default, but comes as a plugin. Install it with this command:

ionic plugin add https://github.com/driftyco/cordova-plugin-wkwebview-engine.git --save

And then add this small change to your config.xml:

<feature name="CDVWKWebViewEngine">
  <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>

<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

You can use feature detection in your JS to differentiate between UIWebView andWKWebView:

if (window.indexedDB) {
   console.log("I'm in WKWebView!");
} else {
   console.log("I'm in UIWebView");
}

Cordova iOS Performance Improvements: Drop-in Speed with WKWebView →

A faster, more stable Chrome on iOS

wkwebview

The Chromium Blog:

In Chrome 48 we’ve made the switch from UIWebView to WKWebView, leading to dramatic improvements in stability, speed, responsiveness, and web compatibility.

The improvements are indeed remarkable and – from a user’s point of view – very noticeable.

Additionally it’s also more stable:

With WKWebView’s out-of-process rendering, when the web view crashes or runs out of memory, it won’t bring down all of Chrome with it. As a result, Chrome crashes 70% less with WKWebView.

A faster, more stable Chrome on iOS →