From 0c89920069320b75d1fa4a47d36b2c48cf85697c Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Sun, 1 Apr 2018 17:35:05 -0700 Subject: [PATCH] Update logic for parsing sdk version number (#15918) * add logic to parse 11.3 sim runtime major version * add null aware and bump group number * add comment describing version --- .../flutter_tools/lib/src/ios/simulators.dart | 4 ++-- .../flutter_tools/test/ios/simulators_test.dart | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index f50aa5bccb8..29e3a094129 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -441,11 +441,11 @@ class IOSSimulator extends Device { @override Future get sdkNameAndVersion async => category; - final RegExp _iosSdkRegExp = new RegExp(r'iOS (\d+)'); + final RegExp _iosSdkRegExp = new RegExp(r'iOS( |-)(\d+)'); Future get sdkMajorVersion async { final Match sdkMatch = _iosSdkRegExp.firstMatch(await sdkNameAndVersion); - return int.parse(sdkMatch.group(1) ?? 11); + return int.parse(sdkMatch?.group(2) ?? 11); } @override diff --git a/packages/flutter_tools/test/ios/simulators_test.dart b/packages/flutter_tools/test/ios/simulators_test.dart index d717f969242..dd2b599caa6 100644 --- a/packages/flutter_tools/test/ios/simulators_test.dart +++ b/packages/flutter_tools/test/ios/simulators_test.dart @@ -94,6 +94,21 @@ void main() { }); }); + group('sdkMajorVersion', () { + // This new version string appears in SimulatorApp-850 CoreSimulator-518.16 beta. + test('can be parsed from iOS-11-3', () async { + final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3'); + + expect(await device.sdkMajorVersion, 11); + }); + + test('can be parsed from iOS 11.2', () async { + final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.2'); + + expect(await device.sdkMajorVersion, 11); + }); + }); + group('IOSSimulator.isSupported', () { testUsingContext('Apple TV is unsupported', () { expect(new IOSSimulator('x', name: 'Apple TV').isSupported(), false);