Menu

Choosing Your WebView in iOS

What's a WebView

A WebView is simply a UI component used to display web content within an app. You can think of mobile Safari as a collection of webviews. Astro is built on top of webviews, not only using them to display web content but also to perform messaging between web and native iOS components.

The Two Options in iOS

In iOS there are two different webview technologies available, each with it's own pros and cons. Historically only UIWebView was available in Astro, however, WKWebView was recently added on an opt-in basis to provide additional features, flexibility, and performance.

UIWebView #

UIWebView is the original webview component introduced in iOS 2.0. This is what has been used since the early days of iOS to build hybrid applications or display any web content within a native app. This is the webview that Astro was originally built on and remains the default for iOS 8.

Advantages

Pitfalls & Problems

WKWebView #

WKWebView was introduced in iOS 8 to give developers a more performant webview (comparable to Safari's webview). WKWebView's rendering is done in a separate process owned by the WKWebView itself and makes use of the Nitro JavaScript engine. As implied by the name, WKWebView uses WebKit for rendering web pages.

Advantages

Pitfalls & Problems

How To Enable WKWebView

Astro promotes using the best web view component for all situations. As a result the default for iOS 9+ is WKWebView and UIWebView for iOS 8. The best web view will be selected on startup based on the version of iOS your app is running on. In rare cases you may need to use UIWebView for all platforms (for example, if you run into a problem where WKWebView doesn't work properly with your website). In this case you can force Astro to use UIWebView for all platforms by adding the following line in your AppDelegate's application:didFinishLaunchingWithOptions: method:

AstroConfig.useWKWebView = false