Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds build number of ios device in flutter devices command #84512

Merged
merged 15 commits into from Jun 23, 2021
27 changes: 25 additions & 2 deletions packages/flutter_tools/lib/src/macos/xcdevice.dart
Expand Up @@ -301,12 +301,21 @@ class XCDevice {
continue;
}

String sdkVersion = _sdkVersion(device);

if (sdkVersion != null) {
final String buildVersion = _buildVersion(device);
balvinderz marked this conversation as resolved.
Show resolved Hide resolved
if (buildVersion != null) {
sdkVersion = '$sdkVersion $buildVersion';
}
}

devices.add(IOSDevice(
device['identifier'] as String,
name: device['name'] as String,
cpuArchitecture: _cpuArchitecture(device),
interfaceType: interface,
sdkVersion: _sdkVersion(device),
sdkVersion: sdkVersion,
iProxy: _iProxy,
fileSystem: globals.fs,
logger: _logger,
Expand All @@ -317,6 +326,7 @@ class XCDevice {
}
}
return devices;

}

/// Despite the name, com.apple.platform.iphoneos includes iPhone, iPads, and all iOS devices.
Expand Down Expand Up @@ -359,8 +369,21 @@ class XCDevice {

static String _sdkVersion(Map<String, dynamic> deviceProperties) {
if (deviceProperties.containsKey('operatingSystemVersion')) {
// Parse out the OS version, ignore the build number in parentheses.
// "13.3 (17C54)"
final RegExp operatingSystemRegex = RegExp(r'(.*) \(.*\)$');
final String operatingSystemVersion = deviceProperties['operatingSystemVersion'] as String;
return operatingSystemRegex.firstMatch(operatingSystemVersion.trim())?.group(1);
}
return null;
}

static String _buildVersion(Map<String, dynamic> deviceProperties) {
if (deviceProperties.containsKey('operatingSystemVersion')) {
//Parse out the build version
balvinderz marked this conversation as resolved.
Show resolved Hide resolved
final RegExp buildVersionRegex = RegExp(r'\(.*\)$');
final String operatingSystemVersion = deviceProperties['operatingSystemVersion'] as String;
return operatingSystemVersion.replaceAll(RegExp('[()]'), '');
return buildVersionRegex.firstMatch(operatingSystemVersion)?.group(0)?.replaceAll(RegExp('[()]'), '');
}
return null;
}
Expand Down