From be228eae787112bafd68bd1a4c0352430805f539 Mon Sep 17 00:00:00 2001 From: xster Date: Thu, 29 Jun 2017 11:54:18 -0700 Subject: [PATCH] Add a dev mode doctor check (#11023) --- .../lib/src/ios/ios_workflow.dart | 10 +++++++++ .../test/ios/ios_workflow_test.dart | 21 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index 4e3589d1dcf..ee87270b3c2 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -49,6 +49,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow { Future get cocoaPodsVersionText async => (await runAsync(['pod', '--version'])).processResult.stdout.trim(); + Future get macDevMode async => (await runAsync(['DevToolsSecurity', '-status'])).processResult.stdout; + Future get _iosDeployIsInstalledAndMeetsVersionCheck async { if (!await hasIosDeploy) return false; @@ -106,6 +108,14 @@ class IOSWorkflow extends DoctorValidator implements Workflow { 'Xcode end user license agreement not signed; open Xcode or run the command \'sudo xcodebuild -license\'.' )); } + if ((await macDevMode).contains('disabled')) { + xcodeStatus = ValidationType.partial; + messages.add(new ValidationMessage.error( + 'Your Mac needs to enabled for developer mode before using Xcode for the first time.\n' + 'Run \'sudo DevToolsSecurity -enable\' or open Xcode' + )); + } + } else { xcodeStatus = ValidationType.missing; if (xcode.xcodeSelectPath == null || xcode.xcodeSelectPath.isEmpty) { diff --git a/packages/flutter_tools/test/ios/ios_workflow_test.dart b/packages/flutter_tools/test/ios/ios_workflow_test.dart index 65fd9ec0a89..cf92c7e8fb7 100644 --- a/packages/flutter_tools/test/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/ios/ios_workflow_test.dart @@ -96,6 +96,20 @@ void main() { Xcode: () => xcode, }); + testUsingContext('Emits partial status when Mac dev mode was never enabled', () async { + when(xcode.isInstalled).thenReturn(true); + when(xcode.xcodeVersionText) + .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); + when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); + when(xcode.eulaSigned).thenReturn(true); + final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(macDevMode: 'Developer mode is currently disabled.'); + final ValidationResult result = await workflow.validate(); + expect(result.type, ValidationType.partial); + }, overrides: { + IMobileDevice: () => iMobileDevice, + Xcode: () => xcode, + }); + testUsingContext('Emits partial status when python six not installed', () async { when(xcode.isInstalled).thenReturn(true); when(xcode.xcodeVersionText) @@ -256,11 +270,13 @@ class IOSWorkflowTestTarget extends IOSWorkflow { bool hasIDeviceInstaller: true, bool hasCocoaPods: true, String cocoaPodsVersionText: '1.2.0', + String macDevMode: 'Developer mode is already enabled.', }) : hasIosDeploy = new Future.value(hasIosDeploy), iosDeployVersionText = new Future.value(iosDeployVersionText), hasIDeviceInstaller = new Future.value(hasIDeviceInstaller), hasCocoaPods = new Future.value(hasCocoaPods), - cocoaPodsVersionText = new Future.value(cocoaPodsVersionText); + cocoaPodsVersionText = new Future.value(cocoaPodsVersionText), + macDevMode = new Future.value(macDevMode); @override final bool hasPythonSixModule; @@ -282,4 +298,7 @@ class IOSWorkflowTestTarget extends IOSWorkflow { @override final Future cocoaPodsVersionText; + + @override + final Future macDevMode; }