iOS UIWebView Deprecating. What does this mean for Cordova apps?

11,396

Solution 1

How can I tell if my app is using UIWebView?

If you use cordova-ios 5.x or lower without any framework, it will use UIWebView by default. If you use cordova-ios 6.0.0 or newer it uses WKWebView.

If you use Ionic, it uses it's own WKWebView plugin by default (if you started the app with Ionic CLI).

If you read the logs when the app starts, it will say, "Using UIWebView", or "Using WKWebView" or "Using Ionic WebView" or other similar messages.

How soon is it expected that Apple will remove UIWebView altogether?

Deprecated only means it's going to go away in the future, we can't know when, but it's safe to use it in iOS 12 and wasn't removed on iOS 13 neither. But you should start migrating as soon as possible. Apple has started showing a warning when an app is submitted, it appears even if you don't use UIWebView anymore because cordova-ios has UIWebView code and it's present in your app even if you switched to WKWebView. It's just a warning for now, but will reject apps in the future. It's still not decided what to do, you can check the discussion

Currently for Cordova apps it is recommended to install the WKWebView engine plugin. Based on the readme all I have to do is install this plugin and it makes Cordova use WKWebView. Is it really that easy? Once this is added I just build and can test knowing the app is using WKWebView only?

Yeah, it's that simple, but the WKWebView has some issues that might affect your app, so give it a try. As explained in the first point, the message should now say "Using WKWebView".

The know issues are reported in the blog post you linked. If they affect you, you can try the Ionic WebView, it uses WKWebView and the WKURLSchemeHandler to solve some of those problems. You don't need to use Ionic to use the Ionic WebView.

Cordova has a local web server plugin you can use wkwebview-engine-localhost that solves some of the problems, but it's not really good to have a web server running in your app.

Solution 2

Cordova just released a version of Cordova iOS to remove UiWebView at compile time.

https://cordova.apache.org/announcements/2019/11/25/cordova-ios-release-5.1.0.html

Changelog:

The most notable improvements in this minor release are:
    The ability to disable UIWebView during the compile-time.

This is the linked PR:

https://github.com/apache/cordova-ios/pull/715
Share:
11,396

Related videos on Youtube

Brad Germain
Author by

Brad Germain

Updated on September 27, 2022

Comments

  • Brad Germain
    Brad Germain over 1 year

    Apple is deprecating UIWebView for iOS 12. (https://cordova.apache.org/news/2018/08/01/future-cordova-ios-webview.html)

    I have a Cordova app and I have a few questions about this change:

    1. How can I tell if my app is using UIWebView?
    2. How soon is it expected that Apple will remove UIWebView altogether?
    3. Currently for Cordova apps it is recommended to install the WKWebView engine plugin. Based on the readme all I have to do is install this plugin and it makes Cordova use WKWebView. Is it really that easy? Once this is added I just build and can test knowing the app is using WKWebView only? https://github.com/apache/cordova-plugin-wkwebview-engine
  • Xatenev
    Xatenev about 5 years
    Update: It has been removed in iOS 12
  • jcesarmobile
    jcesarmobile about 5 years
    No, it's not, just deprecated
  • Faks
    Faks almost 5 years
    This message from the Cordova iOS Github page says that the UIWebview is still available in the iOS 13 beta.
  • jcesarmobile
    jcesarmobile almost 5 years
    Yeah, the comment is mine. I have to update this answer
  • Jacksonkr
    Jacksonkr almost 4 years
    I used cordova-plugin-wkwebvew-engine along with cordova-plugin-wkwebviewxhrfix for my app