Cordova.js will not load on iOS under any circumstances

I’m at my wits’ end troubleshooting this problem. There does not seem to be any useful information on the topic out there so far.

I simply cannot get cordova.js to load on any project in iOS simulator. No amount of reinstalls, cache-clearing, or upgrades for any of ionic, cordova, or npm will fix the problem, from anywhere between ionic 1.7.8 - 1.7.13, cordova 5.3.3 - 5.4.1, and npm 2.7.4 - 3.5.3. I did not use sudo to install any of these.

I have even tried creating a new blank project with no plugins to see if my code or any of the installed plugins were causing the issue. Cordova.js still fails to load.

I am building the project in Xcode 7.2 (on OS X El Capitan 10.11.2) after ionic platform remove ios and ionic platform add ios every time I make a change to my code or environment. I am deploying to iPhone 6S Plus on Simulator. (Using ionic emulate ios launches iPhone 6 simulator, but the app is never loaded onto the simulated device despite terminal displaying BUILD SUCCEEDED and RUN SUCCEEDED.)

I can very clearly see that cordova.js is right there in platforms\ios\www, but when inspecting Simulator in Safari, cordova.js is highlighted in red with “An error occurred trying to load the resource”, which is the same message that I get for script files that don’t exist during testing.

The problem exists on hard devices as well. I had a project that I deployed to an iPad that failed to load any plugins, and therefore could not use $cordovaSQLite due to Error: undefined is not an object(evaluating 'n.sqlitePlugin.openDatabase') openDB@file:///<...>ng-cordova.min.js:9:17883. I reproduced this problem in simulator where cordova.js similarly was not loading. (This $cordovaSQLite issue is not related to $ionicPlatform.ready().)

The problem does not affect Android, which I am building on Windows 7. On that environment, I am able to inspect cordova.js when using Chrome to inspect my project on a device connected via USB.

Has anyone else experienced this problem?

I am having a similar problem, but with cordova_plugins.js. Are you able to check something? If you load the app on an apple device, and open a remote debugger with safari, what happens if you refresh the app from within the debugger?

cordova_plugins.js was also not loading for me, but the remote debugger was not telling me anything.

I eventually isolated the problem to two plugins: cordova-plugin-inappbrowser and cordova-sqlite-storage.

I created a new blank app and added all my plugins, one by one, until I figured out that these two were causing those files not to load. Then I added my www folder back (except for lib/ionic).

Now when I pull new code from my git repository, I then perform the following actions:

Close XCode
ionic platform remove iOS
ionic platform add iOS
cordova prepare
And then open the newly generated xcode project.

This was extremely tedious but is working for me so far.

I have also added my plugins folder to gitignore. I am letting the android development environment and the iOS development environment handle them separately. It was just causing too many problems to use the same code base for the plugins folder.

1 Like