Skip to content

Instantly share code, notes, and snippets.

@xedef
Created April 29, 2015 05:39
Show Gist options
  • Save xedef/5d5094d0b063876094fa to your computer and use it in GitHub Desktop.
Save xedef/5d5094d0b063876094fa to your computer and use it in GitHub Desktop.
Generate iOS Simulators IDs for a given iOS version
/**
* Usage:
* node ios-device-ids.js <ios_version>
*/
var ioslib = require('ioslib'),
_ = require('underscore'),
args = process.argv.slice(2);
if (args && args[0])
{
var version = args[0] + '';
ioslib.simulator.detect(function(err, result){
if (_.has(result.simulators, version))
{
var recipes = loadSimulators(result.simulators[version]);
console.log(JSON.stringify(recipes));
} else {
console.error('iOS SDK version "%s" not installed', version);
}
});
}
function loadSimulators(simulators)
{
var recipes = {};
_.each(simulators, function(simulator){
var recipeId = simulator.deviceType.toLowerCase().replace(/ /g, '');
recipes[recipeId] = ['-C', simulator.udid];
});
return recipes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment