Simulate app on different iOS devices (incl. iPhone 6 and 6 Plus)

Unfortunately I haven’t fount a way to simulate the new iPhones with Cordova’s cordova emulate ios. But luckily, ios-sim 3.0.0 supports the new devices already! So I creates some npm scripts for simulating my app. I hope someone can use it too (improvement suggestions are welcome).

Here’s an excerpt from my package.json:

"scripts": {
    "build-all":     "gulp && cordova build",
    "build-ios":     "gulp && cordova build ios",
    "build-android": "gulp && cordova build android",
    
    "run-all":     "gulp && cordova build && cordova run ios && cordova run android",
    "run-ios":     "gulp && cordova build ios && cordova run ios",
    "run-android": "gulp && cordova build android && cordova run android",
    
    "sim-iphone-4s":        "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 8.0\"",
    "sim-iphone-5":         "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPhone-5, 8.0\"",
    "sim-iphone-5s":        "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 8.0\"",
    "sim-iphone-6":         "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPhone-6, 8.0\"",
    "sim-iphone-6-plus":    "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus, 8.0\"",
    "sim-iphone-resizable": "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone, 8.0\"",
    
    "sim-ipad-2":        "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPad-2, 8.0\"",
    "sim-ipad-retina":   "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 8.0\"",
    "sim-ipad-air":      "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.iPad-Air, 8.0\"",
    "sim-ipad-resizable": "gulp && cordova build ios && ios-sim launch platforms/ios/build/emulator/App\\ Name.app --devicetypeid \"com.apple.CoreSimulator.SimDeviceType.Resizable-iPad, 8.0\""
}

Nice, but you can also switch the device anytime in the Hardware menu.

@Jorick: if you change the device in the hardware menu, how do you get cordova emulate to use the selected hardware next time? For me it always starts in iPhone 4S. I use the cordova emulate iOS --target=“iPad” approach, but that does not support for example Resizable-iPhone.

@ohh2ahh @Jorick Actually I have same problem the simulator always open on iPhone 4/4S, I tried to put your code on the package,json but it didn’t work, can you please tell me the steps to solve this issue, and what will be the command line

Thanks

I have the same problem on OS X Yosemite. Unfortunately I haven’t found a solution yet.

Hi,

You can use ionic emulate ios --target=“iPhone (Retina 4-inch)”.
It works for me and i’m on 10.9.5 with Xcode 6.1

Solution taken from this thread

Actually you can execute command
ios-sim showdevicetypes

Then you will get a list of devices. Use one of them to execute the emulate (example iPhone 4s)
ionic emulate ios --livereload --target=com.apple.CoreSimulator.SimDeviceType.iPhone-4s