WKWebView support for iOS apps

improve this page | report issue

Overview

You can replace the default UIWebView in your MobileFirst hybrid iOS Cordova app with WKWebView.

About this task

With the latest iFix release IBM MobileFirst Platform Foundation V7.1.0 (IF201905221643), you can integrate WKWebView with your hybrid iOS Cordova MobileFirst app.

The cordova-ios version has been updated to 4.0.1 in this iFix release. Ensure that any additional third-party cordova plugin that is added to the project is compatible with the cordova-ios version 4.0.1.

WKWebView provides an improved WebView. WKWebView displays interactive web content, such as for an in-app browser.

Procedure

To enable the WKWebView in a Hybrid MobileFirst app for iOS, follow the below steps.

  1. Open the MobileFirst Hybrid iOS application in Xcode IDE (<ProjectName<>/<AppName>/iphone/native).
  2. Navigate to the Resources/config.xml file and add the following preference under the <widget> tag.

    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

  3. Click Build phases > Link Binary with Libraries > Search for Webkit.framework and add it.
  4. Click CordovaLib.xcodeproj > Build Phases
  5. Add the following header files in the Headers tab as public. These files are located in CordovaLib.xcodeproj/plugin/WKWebview.
    • CDVWKWebViewUIDelegate.h
    • CDVWKProcessPoolFactory.h
    • CDVWKWebViewEngine.h
    • CDVWKWebViewEngine+FileXhrFix.h
  6. Add the following source files in Compile sources tab. These files are located in CordovaLib.xcodeproj/plugin/WKWebview.
    • CDVWKProcessPoolFactory.m
    • CDVWKWebViewEngine+FileXhrFix.m
    • CDVWKWebViewUIDelegate.m
    • CDVWKWebViewEngine.m
  7. Clean and Rebuild the application.

Results

Your MobileFirst hybrid app now uses the WKWebView component instead of the default UIWebView component.

Last modified on June 20, 2019