Cordova: Start Specific iOS Emulator Image

Cordova: start specific iOS emulator image

To find out what are the simulator images available you can use to list them

$ cordova emulate ios --list
Available iOS Virtual Devices:
iPhone-4s, 9.3
iPhone-5, 9.3
iPhone-5s, 9.3
iPhone-6, 9.3
iPhone-6-Plus, 9.3
iPhone-6s, 9.3
iPhone-6s-Plus, 9.3
iPad-2, 9.3
iPad-Retina, 9.3
iPad-Air, 9.3
iPad-Air-2, 9.3
iPad-Pro, 9.3

Then use one of the simulator names in the --target parameter:

cordova emulate ios --target="iPhone-4s, 9.3"
cordova emulate ios --target="iPad-Air-2, 9.3"
cordova emulate ios --target="iPhone-6s, 9.3"
cordova emulate ios --target="iPhone-6-Plus, 9.3"

Important Quit the simulator before launching a different target simulator (On Menu bar select Simulator->Quit)

Take into account that you may need to quit the iOS simulator via menu to switch from 3.5 to 4 inch iPhone.

dynamic list is available in platforms/ios/cordova/lib/list-emulator-images

Not able to emulate ios with Cordova

I suspect that you're running XCode 10. XCode 10 has a new build system which is not yet supported by Cordova.

You should be able to work around this by running the following:

ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"

More information in this issue here: https://github.com/apache/cordova-ios/issues/407

how to pick the ios emulator from cordova / ionic command line

With later versions of Ionic and Cordova one can use any of the following commands to list available emulations. The following commands have been tested with Ionic v3.20.0 and Cordova 8.0.0:

ionic cordova emulate --list # List any OS
cordova run --list # List any OS
cordova run ios --list # List specific OS

And they yield something like:

Available ios virtual devices:
iPhone-5s, 11.2
iPhone-6, 11.2
iPhone-6-Plus, 11.2
iPhone-6s, 11.2
iPhone-6s-Plus, 11.2
iPhone-7, 11.2
iPhone-7-Plus, 11.2
iPhone-8, 11.2
iPhone-8-Plus, 11.2
iPhone-SE, 11.2
iPhone-X, 11.2
iPad-Air, 11.2
iPad-Air-2, 11.2
iPad--5th-generation-, 11.2
iPad-Pro--9-7-inch-, 11.2
iPad-Pro, 11.2
iPad-Pro--12-9-inch---2nd-generation-, 11.2
iPad-Pro--10-5-inch-, 11.2
Apple-Watch-38mm, watchOS 4.2
Apple-Watch-42mm, watchOS 4.2
Apple-Watch-Series-2-38mm, watchOS 4.2
Apple-Watch-Series-2-42mm, watchOS 4.2
Apple-Watch-Series-3-38mm, watchOS 4.2
Apple-Watch-Series-3-42mm, watchOS 4.2
Apple-TV-1080p, tvOS 11.2

To start the emulator with a specific OS use:

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

See also:
https://cordova.apache.org/docs/en/latest/reference/cordova-cli/#cordova-run-command

For an older installation of Ionic and Cordova I used the syntax mentioned in RipTheJacker's answer to select the device to emulate, ie:

ionic emulate ios --target="iPhone-4s"

However, to find out what the available emulations are I run this:

ios-sim showdevicetypes

This command will return a list, something like this:

iPhone-4s, 8.4
iPhone-5, 8.4
iPhone-5s, 8.4
iPhone-6-Plus, 8.4
iPhone-6, 8.4
iPad-2, 8.4
iPad-Retina, 8.4
iPad-Air, 8.4
Resizable-iPhone, 8.4
Resizable-iPad, 8.4

Do I have to run cordova emulate ios everytime

If you want to run your app in a simulator or on a real device you have to go through the native build process every time - yes, thats because you want to run a native app (which needs to be compiled) containing your js part. But for development you could use something like cordova-plugin-browsersync which should speed up your development quite a bit.

Targeting a particular device in the iOS simulator using Meteor

The current solution is to open Xcode by running meteor run ios-device and then select the correct simulator inside Xcode. Unfortunately, ios-sim (the package Meteor uses for the simulator) doesn't make it easy to select the device to simulate.



Related Topics



Leave a reply



Submit