Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordova build iOS error: Cannot read property 'toLowerCase' of undefined with Xcode 9.4.1 #427

Closed
lynzz opened this issue Oct 11, 2018 · 27 comments
Labels
Milestone

Comments

@lynzz
Copy link

lynzz commented Oct 11, 2018

Ionic:

ionic (Ionic CLI) : 4.0.2 (/Users/lzz/.nvm/versions/node/v8.9.1/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.8

Cordova:

cordova (Cordova CLI) : 7.1.0
Cordova Platforms : android 6.3.0, ios 4.5.5

System:

Android SDK Tools : 25.2.3
ios-deploy : 1.9.2
ios-sim : 6.1.2
NodeJS : v8.9.1 (/Users/lzz/.nvm/versions/node/v8.9.1/bin/node)
npm : 5.5.1
OS : macOS Mojave 10.14.1 Beta
Xcode : Xcode 9.4 Build version 9F1027a

Environment:

ANDROID_HOME : /Users/lzz/Library/Android/sdk

Reinstall xcode 10, and such a mistake

Why?

@lynzz lynzz changed the title Cordova build iOS error: Cannot read property 'toLowerCase' of undefined with Xcode 9 Cordova build iOS error: Cannot read property 'toLowerCase' of undefined with Xcode 9.4.1 Oct 11, 2018
@kashban
Copy link
Contributor

kashban commented Oct 11, 2018

I already made a Pull request to fix this:

#428

@lynzz
Copy link
Author

lynzz commented Oct 12, 2018

@kashban Thanks, why would I use xcode 9.4 reported that such a mistake,for macOS 10.14.1 Beta ?

@kashban
Copy link
Contributor

kashban commented Oct 12, 2018

There was an update for the xcode build tools not long ago which was also issued for XCode 10 (not beta), breaking the same stuff. Perhaps it's not bound to Xcode 10.1 beta.

@lynzz
Copy link
Author

lynzz commented Oct 15, 2018

@kashban I merged your PR code, the same error occurs

@kashban
Copy link
Contributor

kashban commented Oct 15, 2018

@lynzz Then your error stems from another source. I am on vacation right now and will be back at Oct 22th.

Please post the complete stack trace of this error into your ticket.

@csabbey
Copy link

csabbey commented Oct 18, 2018

I'm getting the below stack trace. My list-emulator-build-targets line 54 is:
device.availability.toLowerCase().indexOf('unavailable') < 0

It looks like the device availability property got renamed to isAvailable; here's one of the devices:

{ state: 'Shutdown',
  isAvailable: 'YES',
  name: 'iPad Pro (12.9-inch)',
  udid: '5A707375-7596-4375-9A7A-75690B681B46',
  availabilityError: '' }

... and here's the promised stack trace:

TypeError: Cannot read property 'toLowerCase' of undefined
    at /Users/me/code/ms-client-echidna/platforms/ios/cordova/lib/list-emulator-build-targets:54:45
    at Array.forEach (<anonymous>)
    at /Users/me/code/ms-client-echidna/platforms/ios/cordova/lib/list-emulator-build-targets:52:44
    at Array.reduce (<anonymous>)
    at /Users/me/code/ms-client-echidna/platforms/ios/cordova/lib/list-emulator-build-targets:50:57
    at Array.reduce (<anonymous>)
    at /Users/me/code/ms-client-echidna/platforms/ios/cordova/lib/list-emulator-build-targets:45:28
    at _fulfilled (/Users/me/code/ms-client-echidna/platforms/ios/cordova/node_modules/q/q.js:854:54)
    at /Users/me/code/ms-client-echidna/platforms/ios/cordova/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/me/code/ms-client-echidna/platforms/ios/cordova/node_modules/q/q.js:816:13)

@kashban
Copy link
Contributor

kashban commented Oct 18, 2018

That's exactly the issue my PR fixes.

@csabbey
Copy link

csabbey commented Oct 19, 2018

@kashban Yes, it looks like the same issue.

@waflessnet
Copy link

waflessnet commented Oct 22, 2018

@csabbey , yes, i change the "if" line 54 of platforms/ios/cordova/lib/list-emulator-build-targets for:

if (device.name === deviceType.name.replace(/\-inch/g, ' inch') &&  device.isAvailable == 'YES') 

then, the function "availableDevices" is:

 var availableDevices = Object.keys(devices).reduce(function (availAcc, deviceCategory) {
                var availableDevicesInCategory = devices[deviceCategory];
                availableDevicesInCategory.forEach(function (device) {
                        //console.log(device);
                    if (device.name === deviceType.name.replace(/\-inch/g, ' inch') && device.isAvailable == 'YES') {
                            availAcc.push(device);
                        }
                });
                return availAcc;
            }, []);

It works!

PD: if, example your run "ionic cordova build ios" and device "iphone" is conected to mac. the change apply (line 54) is delete. then you must apply it again.

@kashban
Copy link
Contributor

kashban commented Oct 22, 2018

@waflessnet Once my PR is merged and released with the next major version the change will be permanent. It even considers both json formats, so it will be backward compatible.

@felimoles
Copy link

in xcode > 10 dont work :(

@kennybky
Copy link

I had this same problem, but I found a solution. I don't know if it would work for others but I should probably share it in case.
I uninstalled then reinstalled ios platform.
I ran npm update.

Note: I am using cordova without ionic

Cordova: 8.1.2 (cordova-lib@8.1.1)
ios-deploy: 1.9.2
xcode: 9.4.1

@janpio janpio added the bug label Oct 30, 2018
@kashban
Copy link
Contributor

kashban commented Nov 5, 2018

Shouldn't happen anymore with XCode 10.1. Apple reintroduced the former availability property and added a new boolean one called isAvailable.

This accepted merge request takes care of both and will be in the next major release: #451

@Ramprasathselvam
Copy link

K-MacBook-Pro:projectname2.1.7(2.1.7.3) K$ cordova build ios
Cannot read property 'toLowerCase' of undefined

any solution for above issue.

@joeldhenry
Copy link

this started happening on xcode 10.2.1 and i have no solution to get it working again :(

@janpio
Copy link
Member

janpio commented Jun 12, 2019

Create a new issue with all the ncessary information please. Thanks.

@lucasgalli
Copy link

it's happening in Xcode 10.2.1 and i didn't find any solution.

@JillevdW
Copy link

It just happened to me with Xcode 10.2, running on the MacOS Catalina beta. I fixed it by slightly altering the answer @waflessnet gave. Replace the availableDevices function in platforms/ios/cordova/lib/list-emulator-build-targets with the following:

var availableDevices = Object.keys(devices).reduce(function (availAcc, deviceCategory) {
    var availableDevicesInCategory = devices[deviceCategory];
    availableDevicesInCategory.forEach(function (device) {
        if (device && device.name === deviceType.name.replace(/\-inch/g, ' inch') && device.isAvailable == true) {
            availAcc.push(device);
        }
    });
    return availAcc;
}, []);

@lucasgalli
Copy link

I don't know why but I had already tried and just worked it after that I reinstall the Xcode, anyway now it's working, thanks a lot @JillevdW and @waflessnet.

@Matttaylor8910
Copy link

Why is this closed? This still happens with the latest cordova release installed

@brodycj
Copy link
Contributor

brodycj commented Jul 7, 2019

Please raise a new issue with the necessary information, as requested by @janpio. We do not actively support discussions in closed issues. It is fine for the new issue to reference this issue number.

And please keep in mind that this project is maintained by a bunch of overworked volunteers.

@derman10
Copy link

It just happened to me with Xcode 10.2, running on the MacOS Catalina beta. I fixed it by slightly altering the answer @waflessnet gave. Replace the availableDevices function in platforms/ios/cordova/lib/list-emulator-build-targets with the following:

var availableDevices = Object.keys(devices).reduce(function (availAcc, deviceCategory) {
    var availableDevicesInCategory = devices[deviceCategory];
    availableDevicesInCategory.forEach(function (device) {
        if (device && device.name === deviceType.name.replace(/\-inch/g, ' inch') && device.isAvailable == true) {
            availAcc.push(device);
        }
    });
    return availAcc;
}, []);

this solved my problem!
Thanks!!

@ahmadalfy
Copy link

I have cordova 9.0.0 (cordova-lib@9.0.1) and xCode Version 11.0 (11A420a). Still facing this issue

@renatoflorencia
Copy link

I am experiencing the same problem after updating xcode.
My current project has the following versions:

cordova: 8.0.0
ios platform: ^ 4.5.5
xcode: 11.0
ios version: Mojave 10.14

@brodycj
Copy link
Contributor

brodycj commented Sep 25, 2019

Guys please report this kind of thing in a new issue with a reproducible example ([1]) as we do not support discussions in closed issues.

[1] https://stackoverflow.com/help/minimal-reproducible-example

@osmanc777

This comment has been minimized.

@apache apache locked as resolved and limited conversation to collaborators Sep 26, 2019
@brodycj
Copy link
Contributor

brodycj commented Sep 26, 2019

No more discussion on this issue please. Please raise a new issue with the reproducible example.

At this point the maintainers to not have time to actively support use with Ionic. Please consider using Capacitor for Ionic, since Capacitor was designed to work more smoothly with Ionic.

I am now locking this issue as resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests