Skip to content

Commit be228ea

Browse files
authored
Add a dev mode doctor check (flutter#11023)
1 parent 3045c28 commit be228ea

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

packages/flutter_tools/lib/src/ios/ios_workflow.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
4949

5050
Future<String> get cocoaPodsVersionText async => (await runAsync(<String>['pod', '--version'])).processResult.stdout.trim();
5151

52+
Future<String> get macDevMode async => (await runAsync(<String>['DevToolsSecurity', '-status'])).processResult.stdout;
53+
5254
Future<bool> get _iosDeployIsInstalledAndMeetsVersionCheck async {
5355
if (!await hasIosDeploy)
5456
return false;
@@ -106,6 +108,14 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
106108
'Xcode end user license agreement not signed; open Xcode or run the command \'sudo xcodebuild -license\'.'
107109
));
108110
}
111+
if ((await macDevMode).contains('disabled')) {
112+
xcodeStatus = ValidationType.partial;
113+
messages.add(new ValidationMessage.error(
114+
'Your Mac needs to enabled for developer mode before using Xcode for the first time.\n'
115+
'Run \'sudo DevToolsSecurity -enable\' or open Xcode'
116+
));
117+
}
118+
109119
} else {
110120
xcodeStatus = ValidationType.missing;
111121
if (xcode.xcodeSelectPath == null || xcode.xcodeSelectPath.isEmpty) {

packages/flutter_tools/test/ios/ios_workflow_test.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ void main() {
9696
Xcode: () => xcode,
9797
});
9898

99+
testUsingContext('Emits partial status when Mac dev mode was never enabled', () async {
100+
when(xcode.isInstalled).thenReturn(true);
101+
when(xcode.xcodeVersionText)
102+
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
103+
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
104+
when(xcode.eulaSigned).thenReturn(true);
105+
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(macDevMode: 'Developer mode is currently disabled.');
106+
final ValidationResult result = await workflow.validate();
107+
expect(result.type, ValidationType.partial);
108+
}, overrides: <Type, Generator>{
109+
IMobileDevice: () => iMobileDevice,
110+
Xcode: () => xcode,
111+
});
112+
99113
testUsingContext('Emits partial status when python six not installed', () async {
100114
when(xcode.isInstalled).thenReturn(true);
101115
when(xcode.xcodeVersionText)
@@ -256,11 +270,13 @@ class IOSWorkflowTestTarget extends IOSWorkflow {
256270
bool hasIDeviceInstaller: true,
257271
bool hasCocoaPods: true,
258272
String cocoaPodsVersionText: '1.2.0',
273+
String macDevMode: 'Developer mode is already enabled.',
259274
}) : hasIosDeploy = new Future<bool>.value(hasIosDeploy),
260275
iosDeployVersionText = new Future<String>.value(iosDeployVersionText),
261276
hasIDeviceInstaller = new Future<bool>.value(hasIDeviceInstaller),
262277
hasCocoaPods = new Future<bool>.value(hasCocoaPods),
263-
cocoaPodsVersionText = new Future<String>.value(cocoaPodsVersionText);
278+
cocoaPodsVersionText = new Future<String>.value(cocoaPodsVersionText),
279+
macDevMode = new Future<String>.value(macDevMode);
264280

265281
@override
266282
final bool hasPythonSixModule;
@@ -282,4 +298,7 @@ class IOSWorkflowTestTarget extends IOSWorkflow {
282298

283299
@override
284300
final Future<String> cocoaPodsVersionText;
301+
302+
@override
303+
final Future<String> macDevMode;
285304
}

0 commit comments

Comments
 (0)