Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 
like image 388
TestUser Avatar asked Aug 20 '17 04:08

TestUser


2 Answers

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

like image 57
Sampath Avatar answered Nov 13 '22 07:11

Sampath


Remove the iOS version. This worked for me:

cordova emulate ios --target "iPhone-7"
like image 5
Michael Avatar answered Nov 13 '22 08:11

Michael