cordova-ios: Cannot read property 'toLowerCase' of undefined [ERROR] An error occurred while running subprocess cordova.

Bug Report

Running ionic cordova build ios within a new, blank project does not work. This is a continuation of #642

Problem

When running ionic cordova build ios the following error occurs:

Cannot read property 'toLowerCase' of undefined
[ERROR] An error occurred while running subprocess cordova.

What is expected to happen?

The build should run to completion.

What does actually happen?

The build does not run completion.

Information

  1. Create a new Ionic 4 project using the ‘blank’ template.
  2. Add the ios platform using ionic cordova platform add ios.
  3. Upgrade cordova-ios to the latest version (5.0.1 at the time of this writing).
  4. Run ionic cordova build ios. The same TypeError appears.

Command or Code

Environment, Platform, Device

Version information

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.6.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 4 other plugins)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 17 (5 by maintainers)

Most upvoted comments

@brodybits ionic cordova platform add ios@latest worked in a new blank project and in the current project I’m working on (after removing the platform first). Thanks!

I ran npm install cordova-ios@latest […]

I think that will not work on a Cordova project.

I highly recommend that you start with another “blank” project, with a limited number of plugins, and do cordova platform add ios@latest or ionic cordova platform add ios@latest.

In case of continued problems, please give us a more exact set of commands that we have to do to install the Ionic CLI, create the project, add the plugins, and reproduce your issue. Most of us do not actively support use with Ionic.

Updating ios to the latest worked for me~

  1. cordova platform remove ios // To remove existing ios lib.
  2. ionic cordova platform add ios@latest// Update to latest

Cordova Platforms : ios 4.5.5

You are running cordova-ios 4.5.5, this is fixed in cordova-ios 5.0.x.

in my case, the problem was in the file ‘platforms/ios/cordova/lib/list-emulator-build-targets’ line 53 app.

if (device.name === deviceType.name.replace(/\-inch/g, ' inch') && device.availability) { when availability is doesn’t exists.

i change the line for this one. if (device && device.name === deviceType.name.replace(/\-inch/g, ' inch') && device.isAvailable) {

Or we can try these: cordova platform remove ios cordova platform add ios@latest

@MiguelGonzalezAravena just remove the platform ios and then run below command ionic cordova platform add ios@latest as stated by @dpogue above it is fixed in cordova-ios 5.0.x

ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)

This is 4 months old.

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)

This is 9 months old.

Thanks @daviddickson you really saved me a hell lot of time

That your Ionic tool gave you old cordova-ios version indicates to me that you have an old version of Ionic CLI installed. I just tried the following steps:

  • npm i -g ionic
  • ionic start helloWorld blank --type=ionic-angular
  • cd helloWorld
  • ionic cordova platform add ios

and the following piece of output indicates to me that it does use cordova-ios@5, as required:

Using cordova-fetch for cordova-ios@^5.0.0

I highly recommend that you install recent version of Ionic CLI and ensure that you installed recent version of other tools such as Cordova CLI.