layout: post author:
name: Shazron Abdullah
url: https://twitter.com/shazron
title: "Breaking changes coming to the iOS WebView in Apache Cordova" categories: news
With the announcement of the iOS 12 beta SDK at Apple’s WWDC 2018, came the news that UIWebView, the webview originally bundled with the first iOS SDK, has been deprecated. What this means for iOS developers is that sometime in the future, Apple will remove UIWebView from their SDK, and developers should migrate to using the WKWebView component starting right now.
Cordova iOS, starting with version 4, has anticipated this by moving the webview that is used by the platform into a plugin. The default webview that is used is still UIWebView, but you had the option to use WKWebView instead, with the cordova-plugin-wkwebview-engine plugin. Both the UIWebView and WKWebView webviews are plugins themselves, with the former included in the cordova-ios platform.
Starting with a future Cordova iOS release, we will ship both webview plugins with the cordova-ios platform, to enable developers to test and transition users to the new WKWebView component. This future Cordova iOS version will ship with a bridge webview plugin that can switch usage of the webview plugin used at runtime. Previously, you could only choose which webview you would use at build time.
The developer can switch the webview used by setting a preference, that will be read at runtime when the app starts. Developers can transition users to the new WKWebView by user choice, in their app settings -- or randomly perhaps as an A/B test. This will give the developer and their users a chance to try out the new component, and they can back out and use UIWebView if there are any problems, without needing a new app release. This is intended to be used for testing and migration purposes only -- developers should aim to support only WKWebView functionality going forward.
When UIWebView support has been removed in a future iOS SDK, we will aim to release a future Cordova iOS version, which will remove UIWebView support, and WKWebView will then be the default webview engine.
Cordova iOS 4 >>> | Future Cordova iOS >>> | "More Future" Cordova iOS |
---|---|---|
UIWebView deprecated | UIWebView removed | |
WKWebView Engine Plugin Integrated Into Platform | WKWebView Engine Plugin only | |
Bridge WebView Plugin Added | Bridge WebView Plugin Removed |
There are many limitations of WKWebview, especially if you were using UIWebView previously. The limitations are:
There are several bugs that need to be resolved as well. The full list here: https://s.apache.org/QfsF
As you can see, WKWebView is not a direct drop-in replacement for UIWebView, you will need several plugins to patch functionality that is missing. There is also the local-webserver experimental plugin option, which will not be graduated to a full plugin -- we will concentrate our efforts on supporting the main WKWebView engine plugin.
Hopefully with more testing, and filing of bug reports with Apple for missing features, the WKWebView can be a full replacement for Cordova users.
UPDATE 2019-02-16: This blog post has been updated to remove references to these changes going to be included in Cordova iOS 5, as Cordova iOS 5 was released without them and the planned implementation has been moved to a future release of Cordova iOS.