Skip to content

Commit 61bd57c

Browse files
cbrackenMairramer
authored andcommitted
[macOS,iOS] Improve CocoaPods upgrade instructions (flutter#135453)
In our CocoaPods doctor check, if the version of CocoaPods is found to be too low, rather than emitting a link to the install instructions, emit a link to the upgrade instructions. Since this check operates on CocoaPodsStatus, an enum, swtich to using a case statement and cover all cases. ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent b85c868 commit 61bd57c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const String outOfDatePluginsPodfileConsequence = '''
4848

4949
const String cocoaPodsInstallInstructions = 'see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.';
5050

51+
const String cocoaPodsUpdateInstructions = 'see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods for instructions.';
52+
5153
const String podfileIosMigrationInstructions = '''
5254
rm ios/Podfile''';
5355

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,28 @@ class CocoaPodsValidator extends DoctorValidator {
2929
.evaluateCocoaPodsInstallation;
3030

3131
ValidationType status = ValidationType.success;
32-
if (cocoaPodsStatus == CocoaPodsStatus.recommended) {
33-
messages.add(ValidationMessage(_userMessages.cocoaPodsVersion((await _cocoaPods.cocoaPodsVersionText).toString())));
34-
} else {
35-
if (cocoaPodsStatus == CocoaPodsStatus.notInstalled) {
32+
switch (cocoaPodsStatus) {
33+
case CocoaPodsStatus.recommended:
34+
messages.add(ValidationMessage(_userMessages.cocoaPodsVersion((await _cocoaPods.cocoaPodsVersionText).toString())));
35+
case CocoaPodsStatus.notInstalled:
3636
status = ValidationType.missing;
3737
messages.add(ValidationMessage.error(
3838
_userMessages.cocoaPodsMissing(noCocoaPodsConsequence, cocoaPodsInstallInstructions)));
39-
40-
} else if (cocoaPodsStatus == CocoaPodsStatus.brokenInstall) {
39+
case CocoaPodsStatus.brokenInstall:
4140
status = ValidationType.missing;
4241
messages.add(ValidationMessage.error(
4342
_userMessages.cocoaPodsBrokenInstall(brokenCocoaPodsConsequence, cocoaPodsInstallInstructions)));
44-
45-
} else if (cocoaPodsStatus == CocoaPodsStatus.unknownVersion) {
43+
case CocoaPodsStatus.unknownVersion:
4644
status = ValidationType.partial;
4745
messages.add(ValidationMessage.hint(
4846
_userMessages.cocoaPodsUnknownVersion(unknownCocoaPodsConsequence, cocoaPodsInstallInstructions)));
49-
} else {
47+
case CocoaPodsStatus.belowMinimumVersion:
48+
case CocoaPodsStatus.belowRecommendedVersion:
5049
status = ValidationType.partial;
5150
final String currentVersionText = (await _cocoaPods.cocoaPodsVersionText).toString();
5251
messages.add(ValidationMessage.hint(
53-
_userMessages.cocoaPodsOutdated(currentVersionText, cocoaPodsRecommendedVersion.toString(), noCocoaPodsConsequence, cocoaPodsInstallInstructions)));
54-
}
52+
_userMessages.cocoaPodsOutdated(currentVersionText, cocoaPodsRecommendedVersion.toString(), noCocoaPodsConsequence, cocoaPodsUpdateInstructions)));
5553
}
56-
5754
return ValidationResult(status, messages);
5855
}
5956
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void main() {
4141
expect(message.type, ValidationMessageType.hint);
4242
expect(message.message, contains('CocoaPods $currentVersion out of date'));
4343
expect(message.message, contains('(1.11.0 is recommended)'));
44+
expect(message.message, contains('getting-started.html#updating-cocoapods'));
4445
});
4546
});
4647
}

0 commit comments

Comments
 (0)