Remove UIWebview

Submitting to Apple, projects with UIWebview will be rejected in a couple months.

To resolve I added to iOS config.xml

<preference name="WKWebViewOnly" value="true" />

However upon build in Wappler, that line is removed.

Anybody deal with this already?

1 Like

This topic is also very useful for the wkwebview usage:

Thanks that will be helpful at some point.

Today however, I’m focused on the deprecation of UIWebview by Apple. Any reference to it will cause an app rejection in a few months. The fix is what I noted above however I can’t make it work in Wappler.

Is Wappler removing that line?

No we don’t do anything special to remove that line… maybe the Cordova building tools?

But are you really sure about the deprecation? As a lot of apps still use the old webview…

to make sure that its not wappler you can run the command from command line without wappler.
cordova run ios

1 Like

There are several threads out there about ionic and Cordova changes in order to respond to the change by Apple.

I then submitted a test app and received this email…

Dear Developer,

We identified one or more issues with a recent delivery for your app, “Foodist” 0.0.1 (0.0.1). Your delivery was successful, but you may wish to correct the following issues in your next delivery:

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . See https://developer.apple.com/documentation/uikit/uiwebview for more information.

After you’ve corrected the issues, you can upload a new binary to App Store Connect.

Best regards,

1 Like

You’re right. And I think I actually tried that and the file changed. Have to keep trying things!

Thanks Mohammed!

1 Like

Closing the loop on this thread.

Here is the solution that works for me:

  1. Install the cordova-plugin-wkwebview-engine
cordova plugin add cordova-plugin-wkwebview-engine

I added the following to my apache config to deal with CORS. One specific problem was with the CORS preflight check–without dealing with that, myu api was executing twice. With this config, apache just returns a 204 instead of passing to api. Note this is open to all hosts now for testing, but will lock down later.

 # Required configuration for iOS WkWEBVIEW

    # Allow any location to access this service
    Header always set Access-Control-Allow-Origin "*"

    # Allow the following headers in requests (X-Auth is a custom header, also allow Content-Type to be specified)
    Header always set Access-Control-Allow-Headers "X-Auth, content-type, origin"
    Header always set Access-Control-Expose-Headers "X-Auth"

    # Allow the following methods to be used
    Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"

    # WkWebView sends OPTIONS requests to get CORS details. Don't tie up the API service with them;
    # just answer them via apache itself
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} =OPTIONS
    RewriteRule .* - [R=204,END]

Add the following to the config.xml somehwere inside the widget element.

<preference name="WKWebViewOnly" value="true"/>
2 Likes

Cordova published also a blog post about the new usage of WKWebViewOnly:

https://cordova.apache.org/howto/2020/03/18/wkwebviewonly.html

1 Like

For anyone else curious about this, from cordova ios 6+ there is no need to use the wkwebview plugin.

https://cordova.apache.org/howto/2020/07/18/uiwebview-warning.html