Troy Carlson Troy Carlson - 24 days ago 7
AngularJS Question

Scripts/stylesheets not found in Cordova iOS app

I am attempting to port an Angular 1 web app to iOS using Cordova. I've created the Cordova project, added the platforms I need (browser, ios), and copied my production Angular app into the

/www
folder.

When I run
cordova run browser
the app loads as expected in Chrome.

When I run
cordova run ios
the simulator appears, I see the default splash screen, but then all I get is an empty white screen. Using the Safari inspector/console I found that my script and stylesheet references were failing to load:

Failed to load resource: The requested URL was not found on this server.
file:///cordova.js
file:///app.js
file:///app.css
etc...


This is my first Cordova project and I'm not sure how to debug this. Any insight or debugging tips are appreciated.




Screenshots:

Ignore the suffixes on the filenames...those are dynamically generated and I took screenshots from multiple builds. They all match when I run the app locally.

Folder structure

enter image description here

Script tags in index.html

enter image description here

Console errors (from Safari console while app is running on iOS simulator)

enter image description here

config.xml (default values...just to get the damn thing working)

enter image description here

Answer

You should read this post,

Assets not found by Cordova/Phonegap


I found the answer was that someone had introduced

<base href="/">

and I needed

<base href=".">

could be helpful...