Ionic-cli: No target specified for emulator. Deploying to iPhone-SE, 10.3 simulator

Created on 2 Jul 2017  路  16Comments  路  Source: ionic-team/ionic-cli

Bug:

I have tried to run Ionic 3 app on Mac machine.No build errors and working fine on Simulator.But I need to test it on Emulator hence I need to test the Native status bar plugin.

Note: I don't have an iOS device.Hence I'm using rented cloud Mac machine and try to test the iOS status bar implementation.

I have used this cli command:

> ionic cordova run ios

and this too ionic cordova emulate ios same issue.

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.8
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.1.2 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.4.2

System:

    Node       : v6.10.2
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b
    ios-deploy : 1.9.1
    ios-sim    : 6.0.0
    npm        : 3.10.10

Error: No target specified for emulator. Deploying to iPhone-SE, 10.3 simulator

When I run the > cordova run --list --emulator on Mac machine it shows huge list of emulators as like :

iPhone-6, 8.2
iPhone-6, 8.3
iPhone-6, 10.3
iPhone-6, 8.4
iPhone-6, 9.0
iPhone-6, 9.1
iPhone-6, 9.2
iPhone-6, 8.1
iPhone-6, 9.3
iPhone-6-Plus, 8.2
iPhone-6-Plus, 8.3
iPhone-6-Plus, 10.3

I have run this:

ionic cordova run ios --target="iPhone-6, 10.3"

It gives this error.

Error: Cannot read property 'name' of undefined

[ERROR] Cordova encountered an error. You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run ios --target "iPhone-6, 10.3" (exit code 1).

Most helpful comment

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 4.5.0: https://stackoverflow.com/questions/46328873/error-run-on-ios-emulator-after-update-to-ios-11-ionic-3

I was able to fix this by following the directions in the SO answer:

$ 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

And since the latest cordova removed the console plugin: https://stackoverflow.com/a/46344099/457935
You also need to do:

ionic cordova plugin rm cordova-plugin-console

Then everything compiled and deployed from the command line.

All 16 comments

You are on an outdated version of app-scripts. Please run npm install @ionic/app-scripts --save-dev to update to 1.3.12.

If the error persists please run the same command without ionic in front. Maybe also add --debug at the end of the command to get more output. Let us know of the output.

(If the error persists this is probably a Cordova bug, which is used internall by Ionic, but that also means Ionic can do nothing about.)

@janpio I have done the steps which you have mentioned.But no luck yet.Please see it.Thanks.

This is the error without ionic:

cordova run ios --target "iPhone-6, 10.3"
Error: Cannot read property 'name' of undefined


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run ios --target "iPhone-6, 10.3" (exit code 1).

--verbose mode

ionic cordova run ios --target="iPhone-6, 10.3" --verbose
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729
--iscordovaserve --externalIpRequired --nobrowser

[09:41:37]  build dev started ...
[09:41:37]  clean started ...
[09:41:37]  clean finished in 11 ms
[09:41:37]  copy started ...
[09:41:37]  transpile started ...
[09:41:43]  transpile finished in 6.13 s
[09:41:43]  preprocess started ...
[09:41:43]  deeplinks started ...
[09:41:44]  deeplinks finished in 384 ms
[09:41:44]  preprocess finished in 387 ms
[09:41:44]  webpack started ...
[09:41:44]  copy finished in 6.90 s
[09:42:04]  webpack finished in 20.45 s
[09:42:04]  sass started ...
[09:42:07]  sass finished in 3.25 s
[09:42:07]  postprocess started ...
[09:42:07]  postprocess finished in 9 ms
[09:42:07]  lint started ...
[09:42:07]  build dev finished in 30.36 s
> cordova run ios --target "iPhone-6, 10.3"
Error: Cannot read property 'name' of undefined


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova run ios --target "iPhone-6, 10.3" (exit code 1).

ionic info now

ionic info

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.12
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.1.2 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.4.2

System:

    Node       : v6.10.2
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b
    ios-deploy : 1.9.1
    ios-sim    : 6.0.0
    npm        : 3.10.10

@janpio But this is working fine ionic cordova emulate ios as a simulator.When I give a target then above error shows.
This is not working: ionic cordova emulate ios --target="iPhone-6-Plus, 8.2"

Yeah, the "target" command seems to break for some reason.
Try cordova run ios --target="iPhone-6, 10.3" --verbose please.

Yes i get the same issue in ionic 3 somehow --target flag not working. @janpio i try with --verbose flag as well but issue still persist.

@janpio I have already done that and please see my 2nd comment above.I have put the verbose mode output also.Thanks.

@Sampath-Lokuge No you didn't, you ran "ionic cordova ... --verbose" which is different than directly "cordova ... --verbose" and could give you additional output.

@navin10sharma Did you run the cordova ... --verbosecommand? No additional output?

Just found this:
https://issues.apache.org/jira/browse/CB-12888
which links to
https://github.com/phonegap/ios-sim/issues/209

Are you both testing with newest XCode?

I have the same issue

cordova run ios --target="iPhone-6, 10.3" --verbose

gives me in summary:

No scripts found for hook "before_run". No scripts found for hook "before_prepare". This app does not have additional resource files defined Prepared iOS project successfully No scripts found for hook "after_prepare". Error: Cannot read property 'name' of undefined

Same question as I asked the other ones:
Are you testing with newest XCode?

I have this problem with Xcode 8.3.3 Latest version without even specifying a target too

Error: Cannot read property 'replace' of undefined

`
global packages:

@ionic/cli-utils : 1.5.0
Cordova CLI      : 7.0.0 
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts              : 1.3.0
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3 browser 4.1.0 ios 4.4.0
Ionic Framework                 : ionic-angular 3.0.1

System:

Node       : v8.0.0
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 5.0.13 
npm        : 5.0.0

`

If I run

ionic cordova emulate ios --target "iPhone-SE, 10.3"

I have this error:

Error: Cannot read property 'name' of undefined

INFO:

ionic/cli-utils : 1.10.2
ionic (Ionic CLI) : 3.10.3

global packages:

Cordova CLI : 7.0.1

local packages:

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

System:

ios-deploy : 1.9.1
ios-sim    : 6.0.0
Node       : v6.11.2
npm        : 5.4.0
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b

I'm having the same problem, however if I remove the version as Michael suggested here, then I am able to deploy to the Simulator again.

ionic cordova emulate ios --target "iPhone-SE, 10.3"

To

ionic cordova emulate ios --target "iPhone-SE"

Unfortunately this doesn't let me choose between iOS 10.3 and 11.0 but at least can still deploy again.

I have a _hunch_ the comma or whitespace is causing the issue, perhaps the _target_ being passed on to Cordova isn't getting wrapped in quotes?

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 4.5.0: https://stackoverflow.com/questions/46328873/error-run-on-ios-emulator-after-update-to-ios-11-ionic-3

I was able to fix this by following the directions in the SO answer:

$ 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

And since the latest cordova removed the console plugin: https://stackoverflow.com/a/46344099/457935
You also need to do:

ionic cordova plugin rm cordova-plugin-console

Then everything compiled and deployed from the command line.

Thanks a lot. It is working fine now :) @saschwarz

Was this page helpful?
0 / 5 - 0 ratings