blob: fd3c15ad659d4a69af64d6dd9d5757f258ae0c6e [file] [log] [blame]
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import '../base/process.dart';
import '../device.dart';
import '../emulator.dart';
import '../globals.dart' as globals;
import 'ios_workflow.dart';
import 'simulators.dart';
class IOSEmulators extends EmulatorDiscovery {
bool get supportsPlatform => globals.platform.isMacOS;
bool get canListAnything => iosWorkflow.canListEmulators;
Future<List<Emulator>> get emulators async => getEmulators();
class IOSEmulator extends Emulator {
IOSEmulator(String id) : super(id, true);
String get name => 'iOS Simulator';
String get manufacturer => 'Apple';
Category get category =>;
PlatformType get platformType => PlatformType.ios;
Future<void> launch() async {
Future<bool> launchSimulator(List<String> additionalArgs) async {
final List<String> args = <String>[
final RunResult launchResult = await;
if (launchResult.exitCode != 0) {
return false;
return true;
// First run with `-n` to force a device to boot if there isn't already one
if (!await launchSimulator(<String>['-n'])) {
// Run again to force it to Foreground (using -n doesn't force existing
// devices to the foreground)
await launchSimulator(<String>[]);
/// Return the list of iOS Simulators (there can only be zero or one).
List<IOSEmulator> getEmulators() {
final String simulatorPath = globals.xcode.getSimulatorPath();
if (simulatorPath == null) {
return <IOSEmulator>[];
return <IOSEmulator>[IOSEmulator(iosSimulatorId)];