Skip to content

Instantly share code, notes, and snippets.

@cb1kenobi
Last active January 9, 2021 06:53
Show Gist options
  • Save cb1kenobi/19dc4c547864a96bfa9027aae5631e67 to your computer and use it in GitHub Desktop.
Save cb1kenobi/19dc4c547864a96bfa9027aae5631e67 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());
@cb1kenobi
Copy link
Author

@aviboy2006 You probably need to run npm install as sudo.

@AvinashDalvi89
Copy link

Its works as per this tidev/ioslib#114 but actual issue not able to solve using this.

I ran command then i tried tn iphone-8 command

but still same error.

[TRACE] [ioslib] Selected iOS Simulator: iPhone 8 iOS 12.0
[TRACE] [ioslib]   UDID    = 40F2378E-24BC-459C-9E1E-5BA7488BB853
[TRACE] [ioslib]   iOS     = 12.0
[TRACE] [ioslib] Autoselected Xcode: 10.0
[TRACE] [ioslib] Checking if the simulator /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator is already running
[TRACE] [ioslib] Simulator is not running
[TRACE] [ioslib] Tailing iPhone 8 iOS 12.0 Simulator system log: /Users/avinash.dalvi/Library/Logs/CoreSimulator/40F2378E-24BC-459C-9E1E-5BA7488BB853/system.log
[ERROR] Simulator is not available

@cb1kenobi
Copy link
Author

As the error indicates, your simulator is not available. You should try to manually launch it, then reset it. You can also do this via simctl.

Secondly, tn is a community project and is not supported by me or the Titanium team, please use the Appc CLI (or Titanium CLI).

Lastly, this gist is not the correct place to get Titanium support. I recommend hopping on https://ti-slack.slack.com/ or request an account at https://jira.appcelerator.org/ and file a ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment