Home > Blockchain >  Cordova blank page / empty index.html file when running ios app
Cordova blank page / empty index.html file when running ios app

Time:05-24

I'm building my svelte app. In the config.xml file, I'm targeting <content src="./public/index.html" /> which works perfectly on Android.

When I try to launch it on ios:

  1. Splash screen shows.
  2. Splash screen fades into white.
  3. Page is blank and contains:
<html><head></head><body></body></html>

the console has the following error: Failed to load resource: the server responded with a status of 404 () - ionic://localhost

I tried adding:

<preference name="Hostname" value="public" />
or
<preference name="Hostname" value="app" />
or
<preference name="Hostname" value="localhost/public" />

But to no avail.

I'm using the following versions/dependencies:

dependencies:
"cordova": "^11.0.0"
devDependencies:
"cordova-ios": "^6.2.0",
"cordova-plugin-exclude-files": "^1.0.1",
"cordova-plugin-inappbrowser": "^5.0.0",
"cordova-plugin-ionic-webview": "^5.0.0",
"cordova-plugin-splashscreen": "^6.0.1",
"cordova-plugin-whitelist": "^1.3.4"

I've got the following Allows/navigations:

<access launch-external="yes" origin="mailto:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<allow-intent href="mailto:*" />
<allow-navigation href="http://*" />
<allow-navigation href="https://*" />
<allow-navigation href="*" />

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>

Running on macOS Monterey - Version 12.3.1

xcode: Version 13.3.1 (13E500a)

CodePudding user response:

Your problem is with the UIWebView in the ionic-webview. It is no longer available in iOS. You need to switch to capacitor. Capacitor is using WKWebView.

  • Related