diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index 5604f2f618..a8354ff4d2 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -6,7 +6,6 @@ import 'dart:async'; import '../base/common.dart'; import '../base/file_system.dart'; -import '../base/io.dart'; import '../base/os.dart'; import '../base/platform.dart'; import '../base/process.dart'; @@ -33,6 +32,19 @@ class IOSWorkflow extends DoctorValidator implements Workflow { bool get hasIDeviceId => exitsHappy(['idevice_id', '-h']); + bool get hasWorkingLibimobiledevice { + // Verify that libimobiledevice tools are installed. + if (!hasIDeviceId) + return false; + + // If a device is attached, verify that we can get its name. + final String result = runSync(['idevice_id', '-l']); + if (result.isNotEmpty && !exitsHappy(['idevicename'])) + return false; + + return true; + } + bool get hasIDeviceInstaller => exitsHappy(['ideviceinstaller', '-h']); bool get hasIosDeploy => exitsHappy(['ios-deploy', '--version']); @@ -140,6 +152,16 @@ class IOSWorkflow extends DoctorValidator implements Workflow { if (hasHomebrew) { brewStatus = ValidationType.installed; + if (!hasWorkingLibimobiledevice) { + brewStatus = ValidationType.partial; + messages.add(new ValidationMessage.error( + 'libimobiledevice is incompatible with the installed Xcode version. To update, run:\n' + ' brew update\n' + ' brew uninstall --ignore-dependencies libimobiledevice\n' + ' brew install --HEAD libimobiledevice' + )); + } + if (!hasIDeviceInstaller) { brewStatus = ValidationType.partial; messages.add(new ValidationMessage.error( @@ -155,7 +177,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { if (hasIosDeploy) { messages.add(new ValidationMessage('ios-deploy $iosDeployVersionText')); } - if (!hasIDeviceId || !_iosDeployIsInstalledAndMeetsVersionCheck) { + if (!_iosDeployIsInstalledAndMeetsVersionCheck) { brewStatus = ValidationType.partial; if (hasIosDeploy) { messages.add(new ValidationMessage.error( @@ -170,20 +192,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ' brew install ios-deploy' )); } - } else { - // Check for compatibility between libimobiledevice and Xcode. - // TODO(cbracken) remove this check once libimobiledevice > 1.2.0 is released. - final ProcessResult result = (await runAsync(['idevice_id', '-l'])).processResult; - if (result.exitCode == 0 && result.stdout.isNotEmpty && !await exitsHappyAsync(['ideviceName'])) { - brewStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( - 'libimobiledevice is incompatible with the installed Xcode version. To update, run:\n' - ' brew update\n' - ' brew uninstall --ignore-dependencies libimobiledevice\n' - ' brew install --HEAD libimobiledevice' - )); - } } + if (isCocoaPodsInstalledAndMeetsVersionCheck) { if (isCocoaPodsInitialized) { messages.add(new ValidationMessage('CocoaPods version $cocoaPodsVersionText')); diff --git a/packages/flutter_tools/test/ios/ios_workflow_test.dart b/packages/flutter_tools/test/ios/ios_workflow_test.dart index b01bbf8b05..b7502295f4 100644 --- a/packages/flutter_tools/test/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/ios/ios_workflow_test.dart @@ -100,6 +100,18 @@ void main() { expect(result.type, ValidationType.partial); }, overrides: { Xcode: () => xcode }); + testUsingContext('Emits partial status when libimobiledevice is not installed', () 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() + ..hasWorkingLibimobiledevice = false; + final ValidationResult result = await workflow.validate(); + expect(result.type, ValidationType.partial); + }, overrides: { Xcode: () => xcode }); + testUsingContext('Emits partial status when ios-deploy is not installed', () async { when(xcode.isInstalled).thenReturn(true); when(xcode.xcodeVersionText) @@ -209,6 +221,9 @@ class IOSWorkflowTestTarget extends IOSWorkflow { @override bool hasHomebrew = true; + @override + bool hasWorkingLibimobiledevice = true; + @override bool hasIosDeploy = true;