From f5b02e3c05ed1ab31e890add84fb56e35de2d392 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 20 Nov 2018 07:49:29 -0800 Subject: [PATCH] Bump minimum ios_deploy version (#24550) --- .../lib/src/ios/ios_workflow.dart | 2 +- packages/flutter_tools/lib/src/ios/mac.dart | 6 +++ .../test/ios/ios_workflow_test.dart | 39 ++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index 07b30ad377..c8bc17f501 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -49,7 +49,7 @@ class IOSValidator extends DoctorValidator { Future get hasIosDeploy => exitsHappyAsync(['ios-deploy', '--version']); - String get iosDeployMinimumVersion => '1.9.2'; + String get iosDeployMinimumVersion => '1.9.4'; Future get iosDeployVersionText async => (await runAsync(['ios-deploy', '--version'])).processResult.stdout.replaceAll('\n', ''); diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 1847f7808c..845a6961fc 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -105,6 +105,12 @@ class IMobileDevice { Future get isWorking async { if (!isInstalled) return false; + // If usage info is printed in a hyphenated id, we need to update. + const String fakeIphoneId = '00008020-001C2D903C42002E'; + final ProcessResult ideviceResult = (await runAsync(['ideviceinfo', '-u', fakeIphoneId])).processResult; + if (ideviceResult.stdout.contains('Usage: ideviceinfo')) { + return false; + } // If no device is attached, we're unable to detect any problems. Assume all is well. final ProcessResult result = (await runAsync(['idevice_id', '-l'])).processResult; diff --git a/packages/flutter_tools/test/ios/ios_workflow_test.dart b/packages/flutter_tools/test/ios/ios_workflow_test.dart index 1004131a1c..8b531e1ce2 100644 --- a/packages/flutter_tools/test/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/ios/ios_workflow_test.dart @@ -162,6 +162,42 @@ void main() { CocoaPods: () => cocoaPods, }); + testUsingContext('Emits partial status when libimobiledevice is installed but not working', () async { + when(xcode.isInstalled).thenReturn(true); + when(xcode.versionText) + .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); + when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); + when(xcode.eulaSigned).thenReturn(true); + when(xcode.isSimctlInstalled).thenReturn(true); + when(processManager.run( + ['ideviceinfo', '-u', '00008020-001C2D903C42002E'], + workingDirectory: anyNamed('workingDirectory'), + environment: anyNamed('environment')), + ).thenAnswer((Invocation _) async { + final MockProcessResult result = MockProcessResult(); + when(result.stdout).thenReturn(r''' +Usage: ideviceinfo [OPTIONS] +Show information about a connected device. + + -d, --debug enable communication debugging + -s, --simple use a simple connection to avoid auto-pairing with the device + -u, --udid UDID target specific device by its 40-digit device UDID + -q, --domain NAME set domain of query to NAME. Default: None + -k, --key NAME only query key specified by NAME. Default: All keys. + -x, --xml output information as xml plist instead of key/value pairs + -h, --help prints usage information + '''); + }); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); + final ValidationResult result = await workflow.validate(); + expect(result.type, ValidationType.partial); + }, overrides: { + ProcessManager: () => processManager, + Xcode: () => xcode, + CocoaPods: () => cocoaPods, + }); + + testUsingContext('Emits partial status when ios-deploy is not installed', () async { when(xcode.isInstalled).thenReturn(true); when(xcode.versionText) @@ -313,12 +349,13 @@ class MockIMobileDevice extends IMobileDevice { class MockXcode extends Mock implements Xcode {} class MockProcessManager extends Mock implements ProcessManager {} class MockCocoaPods extends Mock implements CocoaPods {} +class MockProcessResult extends Mock implements ProcessResult {} class IOSWorkflowTestTarget extends IOSValidator { IOSWorkflowTestTarget({ this.hasHomebrew = true, bool hasIosDeploy = true, - String iosDeployVersionText = '1.9.2', + String iosDeployVersionText = '1.9.4', bool hasIDeviceInstaller = true, }) : hasIosDeploy = Future.value(hasIosDeploy), iosDeployVersionText = Future.value(iosDeployVersionText),