blob: d0448d217a6dd50e5a5cb583732863412da8f3f2 [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 '../base/io.dart';
import '../build_info.dart';
import '../desktop_device.dart';
import '../device.dart';
import '../globals.dart' as globals;
import '../macos/application_package.dart';
import '../project.dart';
import 'build_macos.dart';
import 'macos_workflow.dart';
/// A device that represents a desktop MacOS target.
class MacOSDevice extends DesktopDevice {
MacOSDevice() : super(
platformType: PlatformType.macos,
ephemeral: false,
bool isSupported() => true;
String get name => 'macOS';
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin_x64;
bool isSupportedForProject(FlutterProject flutterProject) {
return flutterProject.macos.existsSync();
Future<void> buildForDevice(
covariant MacOSApp package, {
String mainPath,
BuildInfo buildInfo,
}) async {
await buildMacOS(
flutterProject: FlutterProject.current(),
buildInfo: buildInfo,
targetOverride: mainPath,
String executablePathForDevice(covariant MacOSApp package, BuildMode buildMode) {
return package.executable(buildMode);
void onAttached(covariant MacOSApp package, BuildMode buildMode, Process process) {
// Bring app to foreground. Ideally this would be done post-launch rather
// than post-attach, since this won't run for release builds, but there's
// no general-purpose way of knowing when a process is far enoug along in
// the launch process for 'open' to foreground it.<String>[
'open', package.applicationBundle(buildMode),
]).then((ProcessResult result) {
if (result.exitCode != 0) {
print('Failed to foreground app; open returned ${result.exitCode}');
class MacOSDevices extends PollingDeviceDiscovery {
MacOSDevices() : super('macOS devices');
bool get supportsPlatform => globals.platform.isMacOS;
bool get canListAnything => macOSWorkflow.canListDevices;
Future<List<Device>> pollingGetDevices() async {
if (!canListAnything) {
return const <Device>[];
return <Device>[
Future<List<String>> getDiagnostics() async => const <String>[];