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

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.Can you tell me why it gives below error? How can I run this on Emulator?

I have used this cli command:

> ionic cordova run ios and this too ionic cordova emulate ios But the 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

Update 2:

I have run this:

ionic cordova run ios --target="iPhone-6, 10.3"
It gives this error.Can you tell me why?

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

1 Like

Have you tried to run the emulator from xCode ? You can open the build project in xCode and run the emulator from there.

@achaheen I’m very new to the Mac environment.You mean, Can I open the Ionic 3 project using Xcode or else? I normally use VS code for developing Ionic 3 apps.Please provide me more info.Thanks.

@sampath No, cordova plugin creates xCode project for the iOS built application after running this command
ionic cordova build ios

You will find this under :
Your_project_directory/platforms/ios/YourAppName.xcodeproj

where YourAppName is your ionic app name.

You can open this file using xCode and build your application or simulate it.

1 Like

@achaheen Oh… Thanks a lot.I’ll try it and will let you know.

@achaheen Thank you so much.I have learned a lot about Xcode and iOS today.It is working perfectly fine. Cheers :slight_smile:

1 Like

Glad to hear that.
Good luck.

1 Like

Initial problem is probably caused by this:

https://issues.apache.org/jira/browse/CB-12888
https://github.com/phonegap/ios-sim/issues/209

1 Like

Won’t work with live reload

If you really want just go into this file your_project_direcotry/platforms/ios/cordova/lib/run.js.
Then find the deployToSim function and replace it with this -

function deployToSim(appPath, target) {
    // Select target device for emulator. Default is 'iPhone-6'
    if (!target) {
        return require('./list-emulator-images').run()
        .then(function (emulators) {
            if (emulators.length > 0) {
                target = emulators[0];
            }
            emulators.forEach(function (emulator) {
              target = emulator;
              events.emit('log', 'EMULATOR' + emulator);
            });
            events.emit('log','No target specified for emulator. Deploying to ' + target + ' simulator');
            return startSim(appPath, target);
        });
    } else {
        return startSim(appPath, target);
    }
}

Then just give the index of whatever emulator you want with target = emulator[x]. You can see the log of the emulator list with ionic run ios -lcs. Stupid workaround, but it seems to work.