Skip to content

Instantly share code, notes, and snippets.

@brentonhouse
Forked from cb1kenobi/resetsims.js
Created October 29, 2019 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentonhouse/8a93707a484e24e10a1a60386ffa5e2d to your computer and use it in GitHub Desktop.
Save brentonhouse/8a93707a484e24e10a1a60386ffa5e2d to your computer and use it in GitHub Desktop.
Resets all iOS, watchOS, and tvOS simulators
'use strict';
const execSync = require('child_process').execSync;
const json = JSON.parse(execSync('xcrun simctl list --json'));
for (const runtime of Object.keys(json.devices)) {
for (const device of json.devices[runtime]) {
console.log(`Removing ${device.name} (${device.udid})`);
execSync(`xcrun simctl delete ${device.udid}`);
}
}
for (const deviceType of json.devicetypes) {
for (const runtime of json.runtimes) {
if (runtime.isAvailable || runtime.availability === '(available)') {
console.log(`\nCreating ${deviceType.name} with ${runtime.name}`);
try {
execSync(`xcrun simctl create '${deviceType.name} ${runtime.name}' ${deviceType.identifier} ${runtime.identifier}`);
console.log('SUCCESS!');
} catch (e) {}
}
}
}
console.log();
console.log(execSync('xcrun simctl list').toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment