Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

in using the ionic emulate command line (i'm assuming it's the same as cordova phoengap) how do I pick the device - either ipad or iphone tall screen. It always defaults to the 3.5" screen.

like image 326
MonkeyBonkey Avatar asked Apr 24 '14 12:04

MonkeyBonkey


People also ask

What is the command for running an app in IOS emulator in ionic framework?

If you wish to run your app on an iPhone SE (2nd generation), run npx react-native run-ios --simulator="iPhone SE (2nd generation)" . The device names correspond to the list of devices available in Xcode. You can check your available devices by running xcrun simctl list devices from the console.


1 Answers

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 
like image 98
John P Avatar answered Sep 20 '22 09:09

John P