Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

Apache Cordova iOS 4.0.0, and WKWebView support

with 34 comments

Webkit_LogoSo we missed the proposed deadline, by a lot.

Release is scheduled to be in the later part of September 2015 now that we’ve got a few devs focused on this. Features have been trimmed, and some have been pushed off to cordova-ios 5.x

We need the community to test.

The test focus should be on plugin stability with the new platform, since it does have API changes. If downstream distribution people are on this list, this concerns your third-party plugins too.

The easiest way to test if it affects your plugin building:

cordova platform add https://github.com/apache/cordova-ios.git 
cordova plugin add your-plugin-id
cordova build

Plugin updates and highlights:

I also want to highlight this scenario which a lot of people will encounter: CB-9592

WKWebView support

The cordova-plugin-wkwebview-engine plugin will be iOS 9 only and it will be a core plugin. The development of this updated plugin is still in progress. Apple has fixed the bug where we couldn’t load documents from file:// urls, and it is iOS 9 only. On non-iOS 9 devices, cordova-ios will fallback to using the UIWebView.

The old version of this plugin used a local webserver to load your main document. This older plugin can be used where you want to use WKWebView in both iOS 8 and iOS 9 deployments, but the plugin will remain as a cordova-labs experiment. This plugin has some re-factoring work to be done.

Issues?

Please post them in our JIRA Issue Tracker, or send pull requests.

Thanks for contributing!

Written by shazron

September 9, 2015 at 6:23 am

Posted in cordova, phonegap

34 Responses

Subscribe to comments with RSS.

  1. What about AppCache support? I Assume it still doesn’t work on iOS 9, is there a shim or anything like that planned? If not, what do you think would be the preferred “offline” strategy?

    Dor Tzur

    September 11, 2015 at 3:46 pm

  2. Awesome. Nice work and excited to test this out. Will we have to support CORS server side for this to work on WKWebView and IOS9?

    Tom Wilson

    September 11, 2015 at 6:26 pm

  3. In your post you mentioned that the wkwebview plugin was still under development. However. The Jira ticket has been marked as resolved. Could you clarify the status? I know the issue was closed the day after your post, but wanted to check if there were any other pending issues.

    Joseph Carroll

    September 14, 2015 at 2:42 pm

    • Hi Joseph,
      Yeah at the time I posted it was still under development, the WKWebView plugin is ready for testing but it hasn’t had an official vote and release yet from Apache, but you can test the candidate using the git url method. I’ll update the blog post soon to reflect the status.

      shazron

      September 14, 2015 at 8:08 pm

  4. Great work all. We are eagerly awaiting this release as our app on 3.x is dead in the water on iOS9. Anything using window.history seems to be broken. Any news on a release date?

    Chris Wallis

    September 30, 2015 at 9:34 am

  5. Hi Shazron

    We are very excited of using WKWebView on our project, specially for performance improvements. I have a question regarding this: should we be able to use wkwebview in the inappbrowser plugin? I mean, opening a website from our apache cordova app using wkwebview.

    Thanks in advance

    Ricardo

    September 30, 2015 at 2:36 pm

  6. ios9 xcode7.0.1 run error?

    ➜ wkwvtest cordova run ios
    Running command: /Users/li/cordovawork/wkwvtest/platforms/ios/cordova/run

    ERROR running one or more of the platforms: Error: /Users/li/cordovawork/wkwvtest/platforms/ios/cordova/run: Command failed with exit code 2
    You may not have the required environment or OS to run this project

    mysoko (@supersoko)

    October 10, 2015 at 7:27 am

  7. Shameless status check.
    What address(s) do we send beer / redbull / snackpacks to to help keep developers fueled?
    😉

    Aaron

    October 13, 2015 at 7:07 pm

  8. I started using the cordova-plugin-wkwebview-engine, but quickly ran into problems. Even in iOS9, file:// support is more restrictive compared to UIWebView:

    1. You cannot start a web-worker from a local .js file
    2. If you load a local image file, CORS prevents you from extracting pixel data.
    3. You cannot use XMLHttpRequest for any file:// url

    Unfortunately, this is standard behavior for desktop web browsers, so I don’t expect Apple to change this in the future. To get the full functionality we used to enjoy in UIWebView, the only solution I see is a local webserver, even in iOS9.

    I’ve switched to using: https://github.com/Telerik-Verified-Plugins/WKWebView
    I have not tried: https://github.com/apache/cordova-plugins/tree/master/wkwebview-engine-localhost

    I’m pushing the WKWebView platform pretty hard. I’m finding bugs and patching them as I go. How can I contribute to the official local-webserver + WKWebView solution?

    Shane

    October 31, 2015 at 2:41 pm

    • Thanks for your investigations Shane, I’m disappointed as well, but we’ll have to work with what we have — unfortunately there will be no easy migration from using UIWebView -> WKWebView, some pain will be involved.

      Your contributions will be great! Just send a pull request to the appropriate repos:
      1. https://github.com/apache/cordova-plugins/tree/master/wkwebview-engine-localhost
      2. https://github.com/apache/cordova-plugin-wkwebview-engine

      shazron

      October 31, 2015 at 8:58 pm

      • @Shazron, is this really true? I’m debugging since 3 hours to upgrade my AngularJS app (using OnsenUI framework). It looks like impossible to load any page inside of my app, as it get loaded with XMLHttpRequest

        Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin.

        XMLHttpRequest cannot load
        Origin null is not allowed by Access-Control-Allow-Origin.

        I tried everything inside of the config.xml – still not possible.. So is this true? XMLHttpRequest won’t work?

        Hirbod

        January 15, 2016 at 3:08 am

      • Sorry for texting you again. Apple is really annoying.. I read some posts about that XML Problem and switched to

        cordova plugin add https://github.com/apache/cordova-plugins.git#master:wkwebview-engine-localhost

        Now, it works – but it is restricted to localhost:port (i set a port because I need localStorage). But my app is still useless, as it needs access to my API (on https://) – I can’t find any documentation, how to remove the restriction for having both localhost and https support. Is it even possible? If not, I don’t really get why WKWebView or the server version should ever be useful in this case..

        Hirbod

        January 15, 2016 at 3:25 am

      • Yeah its a security limitation that was recently added unfortunately (or rather, they didn’t turn it off this time).
        Your https problem, you will need to specify an ATS exception. See http://cordova.apache.org/announcements/2015/12/08/cordova-ios-4.0.0.html where I describe the <access> tag, just specify <access origin=”https://yourserver.com” />

        shazron

        January 15, 2016 at 6:19 am

      • After adding

        // respond to preflights
        if ($_SERVER[‘REQUEST_METHOD’] == ‘OPTIONS’) {
        header(‘Access-Control-Allow-Origin: *’);
        header(“Access-Control-Allow-Headers: Origin, Authtoken, authtoken, X-Requested-With, Content-Type, Accept”);
        exit;
        }
        header(‘Access-Control-Allow-Origin: *’);
        header(“Access-Control-Allow-Headers: Origin, Authtoken, authtoken, X-Requested-With, Content-Type, Accept”);

        into my PHP File / API index.php – it worked. Wow, what a pain. Still seeing some “resizing issues” but it works. Finally. But the pain is to big for this few benefits..

        Hirbod

        January 15, 2016 at 3:56 am

    • Hi,
      i would like to use the https://github.com/apache/cordova-plugins/tree/master/wkwebview-engine-localhost but i need to use localstorage
      when i change the port on localhost i got white screen
      thanks for help

      MATRIX.REAL

      March 22, 2016 at 12:09 am

  9. So excited for this, thanks for all the hard work from you and your team. Curious – i’m assuming there’s compatibility with the most popular plugins e.g Camera, GeoLocation?

    Oliver Shaw (@panicitsollie)

    November 16, 2015 at 2:46 am

  10. Thanks Shaz!

  11. Hi,
    so excited … when it will be published to npm ?
    thank you

    MATRIX.REAL

    December 24, 2015 at 3:53 am

  12. MATRIX.REAL

    December 30, 2015 at 3:40 pm

  13. Hi,
    does the ios cordova 4.X support webgl ?
    thanks

    MATRIX.REAL

    February 1, 2016 at 10:04 pm

    • It uses the underlying UIWebView/WKWebView. So if that supports it, sure. Try caniuse.com

      shazron

      February 1, 2016 at 10:25 pm

  14. WKwebview is incompatible with SQLite/SQLCipher either with native or Cordova projects. Anyone can successfully open the db? Or do you know what issue caused it?

    Philip Viet

    February 26, 2016 at 2:20 pm

  15. It doesn’t support fixed CSS positions, so we’ll have to make the move to the upcoming crosswalk ios plugin; it’s a shame because WK is in every other area we need working great.

    Steven

    March 13, 2016 at 2:23 am


Leave a comment