Skip to content

Commit 32b22b8

Browse files
authored
parse build version on xcodeproj (#105908)
1 parent ddeb0b9 commit 32b22b8

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

packages/flutter_tools/lib/src/ios/xcodeproj.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class XcodeProjectInterpreter {
4747
required FileSystem fileSystem,
4848
required Usage usage,
4949
Version? version,
50+
String? build,
5051
}) : _platform = platform,
5152
_fileSystem = fileSystem,
5253
_logger = logger,
@@ -58,6 +59,7 @@ class XcodeProjectInterpreter {
5859
processManager: processManager,
5960
),
6061
_version = version,
62+
_build = build,
6163
_versionText = version?.toString(),
6264
_usage = usage;
6365

@@ -70,6 +72,7 @@ class XcodeProjectInterpreter {
7072
factory XcodeProjectInterpreter.test({
7173
required ProcessManager processManager,
7274
Version? version = const Version.withText(1000, 0, 0, '1000.0.0'),
75+
String? build = '13C100',
7376
}) {
7477
final Platform platform = FakePlatform(
7578
operatingSystem: 'macos',
@@ -82,6 +85,7 @@ class XcodeProjectInterpreter {
8285
usage: TestUsage(),
8386
logger: BufferLogger.test(),
8487
version: version,
88+
build: build,
8589
);
8690
}
8791

@@ -91,8 +95,7 @@ class XcodeProjectInterpreter {
9195
final OperatingSystemUtils _operatingSystemUtils;
9296
final Logger _logger;
9397
final Usage _usage;
94-
95-
static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+)');
98+
static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+).*Build version (\w+)');
9699

97100
void _updateVersion() {
98101
if (!_platform.isMacOS || !_fileSystem.file('/usr/bin/xcodebuild').existsSync()) {
@@ -118,6 +121,7 @@ class XcodeProjectInterpreter {
118121
final int minorVersion = components.length < 2 ? 0 : int.parse(components[1]);
119122
final int patchVersion = components.length < 3 ? 0 : int.parse(components[2]);
120123
_version = Version(majorVersion, minorVersion, patchVersion);
124+
_build = match.group(2);
121125
} on ProcessException {
122126
// Ignored, leave values null.
123127
}
@@ -134,13 +138,21 @@ class XcodeProjectInterpreter {
134138
}
135139

136140
Version? _version;
141+
String? _build;
137142
Version? get version {
138143
if (_version == null) {
139144
_updateVersion();
140145
}
141146
return _version;
142147
}
143148

149+
String? get build {
150+
if (_build == null) {
151+
_updateVersion();
152+
}
153+
return _build;
154+
}
155+
144156
/// The `xcrun` Xcode command to run or locate development
145157
/// tools and properties.
146158
///

packages/flutter_tools/lib/src/macos/xcode.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class Xcode {
101101

102102
Version? get currentVersion => _xcodeProjectInterpreter.version;
103103

104+
String? get buildVersion => _xcodeProjectInterpreter.build;
105+
104106
String? get versionText => _xcodeProjectInterpreter.versionText;
105107

106108
bool? _eulaSigned;

packages/flutter_tools/lib/src/macos/xcode_validator.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class XcodeValidator extends DoctorValidator {
3737
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
3838
}
3939
}
40+
if (_xcode.buildVersion != null) {
41+
messages.add(ValidationMessage('Build ${_xcode.buildVersion}'));
42+
}
4043
if (!_xcode.isInstalledAndMeetsVersionCheck) {
4144
xcodeStatus = ValidationType.partial;
4245
messages.add(ValidationMessage.error(_userMessages.xcodeOutdated(xcodeRequiredVersion.toString())));

packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ void main() {
146146
]);
147147

148148
expect(xcodeProjectInterpreter.version, Version(11, 4, 1));
149+
expect(xcodeProjectInterpreter.build, '11N111s');
149150
expect(fakeProcessManager, hasNoRemainingExpectations);
150151
});
151152

@@ -173,6 +174,7 @@ void main() {
173174
),
174175
]);
175176
expect(xcodeProjectInterpreter.version, isNull);
177+
expect(xcodeProjectInterpreter.build, isNull);
176178
expect(fakeProcessManager, hasNoRemainingExpectations);
177179
});
178180

packages/flutter_tools/test/general.shard/macos/xcode_validator_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,12 @@ void main() {
183183
final XcodeValidator validator = XcodeValidator(xcode: xcode, userMessages: UserMessages());
184184
final ValidationResult result = await validator.validate();
185185
expect(result.type, ValidationType.installed);
186-
expect(result.messages.length, 1);
186+
expect(result.messages.length, 2);
187187
final ValidationMessage firstMessage = result.messages.first;
188188
expect(firstMessage.type, ValidationMessageType.information);
189189
expect(firstMessage.message, 'Xcode at /Library/Developer/CommandLineTools');
190190
expect(result.statusInfo, '1000.0.0');
191+
expect(result.messages[1].message, 'Build 13C100');
191192
});
192193
});
193194
}

packages/flutter_tools/test/src/context.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
296296
@override
297297
Version get version => Version(13, null, null);
298298

299+
@override
300+
String get build => '13C100';
301+
299302
@override
300303
Future<Map<String, String>> getBuildSettings(
301304
String projectPath, {

0 commit comments

Comments
 (0)