As csantanapr says , you can use:
cordova emulate ios --target="iPhone-4s"
but in this case, the cordova project (or PhoneGap or another) will be launched on the iPhone 4s simulator with iOS version 7.0.3 .
If you want to run a project on the same simulator, but with a different version of iOS (7.1 or 8.0, if it exists on your system)?
From corsa you can make, for example, cobberboy :
launch a special emulator and select the ios version using ios-sim.
But you can improve the --target option of the cordova run command.
First you need to make sure that the target version of iOS is available on your system.
To do this, use cobberboy's answer:
$ ios-sim showdevicetypes
Then you need to open your_project_dir/platforms/ios/cordova/lib/run.js and find the lines of code, as shown below:
// validate target device for ios-sim // Valid values for "--target" (case sensitive): var validTargets = ['iPhone-4s', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6', 'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
To use iPhone-4s, 7.1 (or some others) just add it to the validTargets array.
var validTargets = ['iPhone-4s', 'iPhone-4s, 7.1', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6', 'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
And in
cordova emulate ios --target="iPhone-4s, 7.1"
your --target="iPhone-4s, 7.1" will be valid.
And the deployToSim run.js function:
function deployToSim(appPath, target) { // Select target device for emulator. Default is 'iPhone-6' if (!target) { target = 'iPhone-6'; console.log('No target specified for emulator. Deploying to ' + target + ' simulator'); } var logPath = path.join(cordovaPath, 'console.log'); var simArgs = ['launch', appPath, '--devicetypeid', 'com.apple.CoreSimulator.SimDeviceType.' + target, // We need to redirect simulator output here to use cordova/log command // TODO: Is there any other way to get emulator output to use in log command? '--stderr', logPath, '--stdout', logPath, '--exit']; return spawn('ios-sim', simArgs); }
convert iPhone-4s, 7.1 to a valid argument com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 7.1 for ios-sim .