TestUser
TestUser

Reputation: 61

Cordova cannot read property 'name' of undefined with --target

Whenver I run ionic/cordova emulator command with the --target param specified, I get the cannot read property 'name' of undefined error. Was wondering if anyone else has gotten this before, and if there is a fix available.

Commands Run: ionic cordova emulate ios --target="iPhone-6, 10.3" and ionic cordova emulate ios --target "iPhone-6, 10.3"

Here is my ionic info

cli packages:

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.1.2 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Android SDK Tools : 25.2.2
ios-deploy        : 1.8.5 
ios-sim           : 6.0.0 
Node              : v6.8.1
npm               : 3.10.8 
OS                : macOS Sierra
Xcode             : Xcode 8.3.3 Build version 8E3004b 

Upvotes: 6

Views: 10027

Answers (6)

saberprashant
saberprashant

Reputation: 474

For those who are still facing this issue in 2020 with the current setup:

ionic 3
iOS 13 simulators
Xcode - 11.3.1
iOS cordova@4 (the version I was using -> 4.5.5)

Please update your iOS cordova platform to v5 like:

ionic cordova platform rm ios

then

ionic cordova platform add ios@5  (this will add ios - 5.1.1 which is 
current right now)

Don't forget to update the resources, as you might find some "Cordova bot" images in your resources under "Xcode assets".

PS: I tried all the listed solutions, but nothing worked for me. Also, I got a newsletter from Ionic team stating that Apple might discontinue some of the features related to "webKitView", and they recommended to use "cordova iOS v5" platform. So, I think it's a good time to upgrade your platform.

Upvotes: 2

zoomlar
zoomlar

Reputation: 411

In Xcode 10.3 I had to

  1. open Xcode and select iOS version I wanted to test. (Like Android Studio... awkward...) Download Simulators
    1. then, cordova run ios --list returned stuff.

In Xcode 10.3 I had to open Xcode and select iOS version I wanted to test. (Like Android Studio.) Then, **cordova run ios --list** returned stuff.

Upvotes: 1

Sampath
Sampath

Reputation: 65870

If you run the following and get no devices (as shown):

cordova run ios --list
Available ios devices:
Available ios virtual devices:

This is likely due to Ionic specifying old ios-sim version 4.4.0 instead of the latest.

cd platforms/ios/cordova && npm install ios-sim@latest
$ cd ../../../
$ cordova platform rm ios
$ cordova platform add [email protected]
$ ionic cordova emulate ios --target --list
> cordova run ios --list --target --emulator
Available ios devices:

Available ios virtual devices:

iPhone-5s, 11.0
iPhone-6, 11.0
iPhone-6-Plus, 11.0
iPhone-6s, 11.0
iPhone-6s-Plus, 11.0
iPad-Air, 11.0
iPad-Air-2, 11.0
iPhone-7, 11.0
iPhone-7-Plus, 11.0
iPhone-SE, 11.0
iPad--5th-generation-, 11.0
iPad-Pro--12-9-inch---2nd-generation-, 11.0
iPad-Pro--10-5-inch-, 11.0
Apple-Watch-38mm, watchOS 4.0
Apple-Watch-42mm, watchOS 4.0
Apple-Watch-Series-2-38mm, watchOS 4.0
Apple-Watch-Series-2-42mm, watchOS 4.0
Apple-TV-1080p, tvOS 11.0
Apple-TV-4K-4K, tvOS 11.0
Apple-TV-4K-1080p, tvOS 11.0
iPad-Pro--9-7-inch-, 11.0
iPad-Pro, 11.0

You can read more about this issue here on Git

Upvotes: 8

Michael
Michael

Reputation: 51

Remove the iOS version. This worked for me:

cordova emulate ios --target "iPhone-7"

Upvotes: 5

Pavel Kovalev
Pavel Kovalev

Reputation: 8116

Looks like this is your guy:

issues.apache.org: cordova emulate ios with --target throws undefined error

They are saying that it was fixed in [email protected]

So try to do

sudo npm install cordova-ios@latest

and it should fix your issue and probably bring a few new issues 🙂

I hope it helps.

Upvotes: 1

Jake Xuereb
Jake Xuereb

Reputation: 223

First use xcode to create and name the emulator (I suggest using an easy to type name). Then once you've done this you may run the emulator either through xcode itself by running the project in this IDE or using CLI commands. Ref:-https://developer.apple.com/library/content/documentation/IDEs/Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/TestingontheiOSSimulator.html#//apple_ref/doc/uid/TP40012848-CH4-SW1

Upvotes: 0

Related Questions