cordova build ios but error in 'Cannot read property 'toLowerCase' of undefined'

Viewed 5506

I use ionic3 and cordova@8.1.2. Recently my Xcode update to 11.1 and error occured [Cannot read property 'toLowerCase' of undefined].I tried this way: change:

if (device.name === deviceType.name.replace(/\-inch/g, ' inch') &&
    device.availability.toLowerCase().indexOf('unavailable') < 0) {
    availAcc.push(device);
 }

to:

if (device.name === deviceType.name.replace(/\-inch/g, ' inch')) {
if ((device.availability && device.availability.toLowerCase().indexOf('unavailable') < 0)
|| device.isAvailable == 'YES') {
// XCode 10 and lower
availAcc.push(device);
}
}

Then error occurred in

Cannot read property 'name' of undefined

I cannot find where is this 'name'.

3 Answers

Remove platform ios and again add platform ios.
It's working for myself.

cordova platform rm ios
cordova platform add ios

My cordova version is 8.1.2. I encountered the same problem recently on ios.Please check your Android or Ios version and make it to latest if you're using older version of it. You don't need to add/modify any code to list-emulator-build file(cordova/lib/list-emulator-build). It'll be certainly working. latest version of ios is ios(5.0.1).

Steps to solve this error:

  1. Connect your iPhone device.
  2. Open Xcode and select your iPhone device.
  3. Run command in terminal: ionic cordova build ios
Related