getBootedSimulator static method
Get booted simulator ID
Implementation
static Future<String?> getBootedSimulator() async {
try {
final result = await Process.run('xcrun', [
'simctl',
'list',
'devices',
'booted',
]);
if (result.exitCode == 0) {
final output = result.stdout as String;
// Parse output to find booted device
final lines = output.split('\n');
for (final line in lines) {
if (line.contains('Booted')) {
// Extract device ID (format: " iPhone 15 Pro (ABC12345-6789-...) (Booted)")
final match = RegExp(r'\(([A-F0-9-]+)\)').firstMatch(line);
if (match != null) {
return match.group(1);
}
}
}
}
return null;
} catch (e) {
return null;
}
}