Ionic Emulate More Devices

Change Device to Emulate iOS [ionic notebook]

Running $ ionic emulate starts simulator but only the default device. There’s --target switch but the name of the device is, let’s say hard to type.

Tip: Command to see list of available devices: $ ios-sim showdevicetypes

Source of this tip can be found in the ionic forum and here’s my addition:

$ cd ~/Applications
$ touch ionicemulate.sh

Edit the ionicemulate script:

#!/bin/bash
export DEVICES=`ios-sim showdevicetypes 2>&1`
export DEVICES=\"`echo $DEVICES | sed -e 's/ com./" "com./g' | sed -e 's/, /,~/g'`\"
PS3='Please enter your choice: '
options=($DEVICES)
app="`find ./platforms/ios/build/emulator/ -name *.app -print`"
escaped_app="\"$app\""

echo $app
select opt in "${options[@]}"
do
    case $opt in
        *) echo ios-sim launch "$escaped_app" --devicetypeid "`echo $opt | sed -e "s/~/ /g"`" --stderr ./platforms/ios/cordova/console.log --stdout ./platforms/ios/cordova/console.log > tmp.run.file;chmod +x tmp.run.file;./tmp.run.file;rm tmp.run.file;exit;
    esac
done

Edit ./bash_profile and add line:

alias ionicemulate='~/Applications/ionicemulate.sh'

Restart Terminal app. Now you can use ionicemulate command:

$ ionicemulate

Enjoy!