Having trouble with UIWebView / WKWebview

Just iOS. The Android build worked fine.

Make a dev build and run it on your device (while it’s tethered to your Mac.

Open Safari and look at the Develop menu. If you don’t have one, check this out: https://osxdaily.com/2011/11/03/enable-the-develop-menu-in-safari/

Now start remote debugging: https://appletoolbox.com/use-web-inspector-debug-mobile-safari/

I’m hoping the console window will have messages which give a hint as to what is going on.

Ok. I’ve added the develop menu on the mac and web inspector on the device and tethered the iphone. However, nothing happens when I open the app. Note, it is built as an “Enterprise” app. I believe I need to enter a URL in the mobile safari for it to debug on the mac?

Try making a Development (“dev”) build.

I created a dev cert and provisioning profile and created the app using these settings:
“iosPackageType”: “ad-hoc”,
“platform”: “ios”,
“release”: “debug”
I’m still not seeing it in safari when run on the iphone. I select Iphone in the develop list and it says “no inspectable applications”

Did you go through the suggestions here?

Ok. After rebooting the Mac and restarting the phone I was able to debug from the browser. Unfortunately, the console is empty. I created a super basic test app (one page hello app) and it works fine until I added the WKWebView code referenced in the documentation. At that point it just goes to a blank white screen.

After reloading the app in safari in debug, it will not load any of the html files -

First error is "Cross origin requests are only supported for HTTP.

Then each layout gives an error -"XML HttpRequest cannot load file:///private/var/containers/Bundle/application… .html due to access control checks

So looks like a CORS error when using WKWebView

Good news - I added the following and so far it appears to get around the CORS issue -

  plugin name="cordova-plugin-wkwebview-engine"/
  plugin name="cordova-plugin-wkwebview-file-xhr"/
  plugin name="https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix"/
  plugin name="cordova-plugin-inappbrowser"/

One odd behavior is that it broke - plugin name="cordova-plugin-webviewcolor"

I’m not sure what you’re doing, but could you also handle the CORS issues with something like this?

<plugin name="cordova-plugin-whitelist" source="npm" />
  <access origin="https://*.xxx.com" />
  <access launch-external="yes" origin="tel:*" />
  <allow-intent href="https://*.xxx.com" />
  <allow-intent href="tel:" />
  <allow-navigation href="*" />
  <access origin="*" />

I think you can also specify Content Security Policy in the meta data on your index page:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' gap://ready file:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src 'self'; img-src 'self'; connect-src https://*.xxx.com tel:;" />

Cordova just published this blog post which looks useful:


Thanks. I tried building with this setting in config.xml to use Cordova 6.0.1 -

preference name=“cordova-ios” version=“6.0.1” /

But when I look at the cordova.js file in the web inspector it still shows ‘5.1.1’

The correct directive is

<engine name="ios" spec="6.1.0" />

Tip: if you enclose special text in left ticks (`), you can put less than signs in your messages.

Thanks. Unfortunately adding the engine results in a Volt Build error -

<engine name="ios" spec="6.1.0" />

Error: Unpacking p12 file failed. Check your p12 file. Build ID: 023b7436-6488-40ff-9fdc-daf76727c3e6

Can you double check it’s the only thing which changed? If you take out the engine statement, does it work again?

yes. It’s the only thing that changed and removing it allows it to build again.

That doesn’t look like it’s a VoltBuilder thing. The error is being raised from Cordova when creating the iOS platform. Probably something to do with the new version of iOS support.

Wait - are you intending to use engine 6.0.1, or the current one: 6.1.0?

Doh. I mis-typed the version - just corrected to 6.1.0 and retrying.

Ok. The engine 6.1.0 works and allows the app to build. Should I remove all references to WKWebview then? Including the feature and preference names?