Using WKWebView for your hybrid iOS apps

Reading Time: 2 minutes

Since many years UIWebview was used as the container in which the webpart of any Cordova based hybrid project was viewed, increasing in functionality and stability along the years. But it never felt really snappy and had some issues for more complicated projects and the world of GUI frameworks that seems to be in Flux all the time.

Shaky

Since iOS 8 was introduced back in 2014 Apple decided it was time to implement a new and modern vision on their Webkit API. In the center of this new version is WKWebview, created for iOS 8 & OS X Yosemite and newer versions.

The biggest pro for using WKWebview over the older UIWebview? Speed! Especially for hybrid apps, almost entirely consisting out of logic and view creation in the webbased code layer, seem to thrive on the speed that this renderer brings along.
Besides that, some inconsistencies and memory leaking have become things of the past, making it THE component to use for hybrid apps.

Now, 2015 and iOS 9 rolled out freshly on the 16th of September, there are a couple of options one could follow to embrace the new webviewing component. This post describes some of the most interesting options available as of September 2015.

Read more after the break.

[ad name=”Generic Large Mobile Banner 320 x 100″]

First of all, read up on Mattt Thompson’s writing on NSHipster about WKWebView to get a sense for its need and history.
Although the SDK has been updated and WKWebview is present it doesn’t appear to be a very easy fit for frameworks like Cordova just yet. Work still has to be done as it appears, but they’re getting there.

So with that info in the back of your mind, here are the options you can take on using WKWebView for your hybrid app as of today:

  1. The easiest but most anticipated: Wait for Cordova to implement it as a default
    This will give you the most stable and thorough setup for your apps although we have to see if backwards compatibility towards pre-iOS 8 versions will be included
  2. Usa a Cordova plugin that utilises the WKWebView component and get going with this right away
    Eddy Verbruggen has a nice WKWebView plugin on github that works well and even Holly Schinsky wrote down a post about it and gives it preps for resulting in a speed boost
  3. You remember that cool Crosswalk project that makes your hybrid Android project superfast and more OS independent? Guess what, they’ve got an iOS variant using WKWebView
    If that ain’t cool! The people from the Crosswalk crew are working on a sibling solution for iOS too. Quality guaranteed.

Although the first one will probable be the best in a long-term relation it is perfectly understandable that you want your iOS hybrid solution to profit from a speed increase as of today.

Take your pick on how to achieve light speed and in the meanwhile, keep an eye on this twitter account which is monitoring WKWebView developments and take a look at what the main hybrid frameworks like Ionic framework are doing with WKWebview.

And hurry, because it won’t be too long before we all can dip our projects in this secret sauce and get going with it!

Speed of light