AshleysBrain AshleysBrain - 1 year ago 208
iOS Question

State of WKWebView on Cordova iOS 9?

iOS 8 introduced WKWebView, a modernised web view for iOS with more features, particularly notably JIT compilation for Javascript code which significantly improves performance.

However WKWebView on iOS 8 had some bugs which prevented Cordova using it by default. AFAIK there are plugins that can use it, but they all say "beta", "incomplete" etc. Also as far as I'm aware iOS 9 fixes the bugs that stopped Cordova defaulting to WKWebView in iOS 8.

So what is the state of WKWebView in Cordova on iOS 9? I can't seem to find any information about this. Does Cordova default to WKWebView on iOS 9? If not why not, and can it be officially enabled another way?

Answer Source

New edit: 9 december 2015

cordova ios 4.0.0 has been released and the version 1.0.0 of cordova-plugin-wkwebview-engine

To try it:

cordova create wkwvtest wkwvtest
cd wkwvtest
cordova platform add ios@4
cordova plugin add cordova-plugin-wkwebview-engine

As I already told, cordova-plugin-wkwebview-engine only supports iOS 9, on iOS 8 it will use UIWebView and has some know issues

If you want to support iOS 8 too, you can use the wkwebview-engine-localhost (experimental) or cordova-plugin-wkwebview from Telerik, both of them use a local web server


You can use WKWebView with cordova using the WKWebView plugins available.

The problem you mention is that WKWebView can't load local files, so the plugins use a local web server to workaround the problem.

There are some of them like this one from telerik (with the web server built in) or the official from cordova team (with the web server as dependency plugin)

As the bug you mention is fixed on iOS 9, the current cordova plugin (compatible with iOS 8 and iOS 9, using the web server) has been renamed to wkwebview-engine-localhost, and the current name cordova-plugin-wkwebview-engine will be used for a new plugin that will support iOS 9 only and won't use the web server

You can see the issues to track the progress here

EDIT: I bring news

WKWebView support

The cordova-plugin-wkwebview-engine plugin will be iOS 9 only and it will be a core plugin. The development of this updated plugin is still in progress. Apple has fixed the bug where we couldn’t load documents from file:// urls, and it is iOS 9 only. On non-iOS 9 devices, cordova-ios will fallback to using the UIWebView.

The old version of this plugin used a local webserver to load your main document. This older plugin can be used where you want to use WKWebView in both iOS 8 and iOS 9 deployments, but the plugin will remain as a cordova-labs experiment. This plugin has some re-factoring work to be done.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download