liqin
liqin

Reputation: 51

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

I use ionic3 and [email protected]. 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'.

Upvotes: 5

Views: 6622

Answers (3)

Upkar Chaurasia
Upkar Chaurasia

Reputation: 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

Upvotes: 0

Arghya Chowdhury
Arghya Chowdhury

Reputation: 328

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).

Upvotes: 0

Ramprasath Selvam
Ramprasath Selvam

Reputation: 4448

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

cordova platform rm ios
cordova platform add ios

Upvotes: 11

Related Questions