Ionic 4 - UIWebView references

Hello,

I currently have an Ionic 4 application where I use Cordova. I know they are working through how best to resolve the issue of removing UIWebView in their ios platform and various plugins.

I am trying to understand how to determine that you do not have any references to UIWebView that Apple might eventually reject my app. From what I have read it does not matter if the UIWebView reference is a comment or not?

I just created a brand new blank Ionic 4 application. I then grep through the entire project and saw @ionic/core had references to UIWebView where a check is done and comments in the code:

isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(win.navigator.userAgent)

node_modules/@ionic/core/dist/ionic/swiper/swiper.bundle.js
node_modules/@ionic/core/dist/collection/components/slides/swiper/swiper.bundle.js
node_modules/@ionic/core/dist/esm/swiper.bundle-ccdaac54.js
node_modules/@ionic/core/dist/esm-es5/swiper.bundle-ccdaac54.js
node_modules/@ionic/core/dist/cjs/swiper.bundle-f80f3318.js
node_modules/@ionic/core/hydrate/ionic-hydrate.js

NOTE: Doing the grep returned a number of references to UIWebView besides the ones I listed above.

I then added cordova-ios@5.1.1 and followed the instructions here:

  • Ensure you have a WKWebView plugin installed: either the official Apache one or Ionic’s. All Ionic starter apps automatically include cordova-plugin-ionic-webview .
  • Add <preference name="WKWebViewOnly" value="true" /> to your config.xml file.
  • Run cordova prepare ios to apply the changes.

I then build a production ready version of the blank starter app.

ionic cordova build ios --prod --release

If I then open up the project in Xcode and search through it I see 120 references to UIWebView in 20 files.

If I build and .ipa file and unzip it (i.e. change .ipa to .zip and unzip) followed by doing a grep through the Payload folder it returns that the app has references to UIWebView:

>> grep -lr "UIWebView" *
>> MyApp.app/MyApp

I am at a loss as to how to remove reference to UIWebView in my starter application and my current production application (this has additional cordova plugins - inappbrowser).

Any insight on how to remove references to UIWebView in applications and determine that you have to the point that it will satisfy Apple would be greatly appreciated.

1 Like

No, Apple not just checks for references to UIWebView text, they actually check that you have code were the UIWebView is allocated. And they are able to detect if the code is commented.

I know because I tested it.

1 Like

Thanks for the response. I just want to make sure I understand.

Apple will check to see if there are any references in your bundle for UIWebView -

  • actual UIWebView code or comments in the code? So any reference at all?

If that is the case, why when I grep the bundle for a brand new ionic 4 blank app with cordova-ios 5.1.1 (preference name=“WKWebViewOnly” value=“true” set in config.xml) have instances of UIWebView in it?

How do you go about removing all these references?

no, they don’t search for the UIWebView string, they check that the UIWebView is created, they don’t grep as you are doing.

WKWebViewOnly preference just sets a compile time variable that disables the UIWebView, but doesn’t remove any code, so you’ll still see if if you search.

Not sure how Apple checks it, but they are able to detect if you are using it or not.

4 Likes

Thanks you! That answers my question.

I am facing the same issue as mentioned
I have added the same, still my app is getting rejection
I also update all the plugin to latest version
Any solution?