diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index bc553fa9fd..43c9e9f074 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -87,7 +87,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { } } else { xcodeStatus = ValidationType.missing; - if (xcode.xcodeSelectPath.isEmpty) { + if (xcode.xcodeSelectPath == null || xcode.xcodeSelectPath.isEmpty) { messages.add(new ValidationMessage.error( 'Xcode not installed; this is necessary for iOS development.\n' 'Download at https://developer.apple.com/xcode/download/.' diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index f2a85acfa6..3f04029cc0 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -29,8 +29,8 @@ class Xcode { _eulaSigned = false; try { - _xcodeSelectPath = runSync(['xcode-select', '--print-path']); - if (_xcodeSelectPath == null || _xcodeSelectPath.trim().isEmpty) { + _xcodeSelectPath = runSync(['xcode-select', '--print-path'])?.trim(); + if (_xcodeSelectPath == null || _xcodeSelectPath.isEmpty) { _isInstalled = false; return; } diff --git a/packages/flutter_tools/test/src/ios/ios_workflow_test.dart b/packages/flutter_tools/test/src/ios/ios_workflow_test.dart index a7e47de093..404472d295 100644 --- a/packages/flutter_tools/test/src/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/src/ios/ios_workflow_test.dart @@ -20,7 +20,7 @@ void main() { testUsingContext('Emit missing status when nothing is installed', () async { when(xcode.isInstalled).thenReturn(false); - when(xcode.xcodeSelectPath).thenReturn(''); + when(xcode.xcodeSelectPath).thenReturn(null); IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget() ..hasPythonSixModule = false ..hasHomebrew = false @@ -31,7 +31,7 @@ void main() { testUsingContext('Emits partial status when Xcode is not installed', () async { when(xcode.isInstalled).thenReturn(false); - when(xcode.xcodeSelectPath).thenReturn(''); + when(xcode.xcodeSelectPath).thenReturn(null); IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial);