
This tweaks the Flutter doctor messages for CocoaPods. This also switches the "unknown version" error to link to the update instructions instead of the installation instructions; the user has already installed CocoaPods in this scenario. Example error before: ``` â CocoaPods not installed. CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions. ``` Example error after: ``` â CocoaPods not installed. CocoaPods is a package manager for iOS or macOS platform code. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation ```
57 lines
2.3 KiB
Dart
57 lines
2.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import '../base/user_messages.dart';
|
|
import '../doctor_validator.dart';
|
|
import 'cocoapods.dart';
|
|
|
|
/// A validator that confirms cocoapods is in a valid state.
|
|
///
|
|
/// See also:
|
|
/// * [CocoaPods], for the interface to the cocoapods command line tool.
|
|
class CocoaPodsValidator extends DoctorValidator {
|
|
CocoaPodsValidator(
|
|
CocoaPods cocoaPods,
|
|
UserMessages userMessages,
|
|
) : _cocoaPods = cocoaPods,
|
|
_userMessages = userMessages,
|
|
super('CocoaPods subvalidator');
|
|
|
|
final CocoaPods _cocoaPods;
|
|
final UserMessages _userMessages;
|
|
|
|
@override
|
|
Future<ValidationResult> validate() async {
|
|
final List<ValidationMessage> messages = <ValidationMessage>[];
|
|
|
|
final CocoaPodsStatus cocoaPodsStatus = await _cocoaPods
|
|
.evaluateCocoaPodsInstallation;
|
|
|
|
ValidationType status = ValidationType.success;
|
|
switch (cocoaPodsStatus) {
|
|
case CocoaPodsStatus.recommended:
|
|
messages.add(ValidationMessage(_userMessages.cocoaPodsVersion((await _cocoaPods.cocoaPodsVersionText).toString())));
|
|
case CocoaPodsStatus.notInstalled:
|
|
status = ValidationType.missing;
|
|
messages.add(ValidationMessage.error(
|
|
_userMessages.cocoaPodsMissing(noCocoaPodsConsequence, cocoaPodsInstallInstructions)));
|
|
case CocoaPodsStatus.brokenInstall:
|
|
status = ValidationType.missing;
|
|
messages.add(ValidationMessage.error(
|
|
_userMessages.cocoaPodsBrokenInstall(brokenCocoaPodsConsequence, cocoaPodsInstallInstructions)));
|
|
case CocoaPodsStatus.unknownVersion:
|
|
status = ValidationType.partial;
|
|
messages.add(ValidationMessage.hint(
|
|
_userMessages.cocoaPodsUnknownVersion(unknownCocoaPodsConsequence, cocoaPodsUpdateInstructions)));
|
|
case CocoaPodsStatus.belowMinimumVersion:
|
|
case CocoaPodsStatus.belowRecommendedVersion:
|
|
status = ValidationType.partial;
|
|
final String currentVersionText = (await _cocoaPods.cocoaPodsVersionText).toString();
|
|
messages.add(ValidationMessage.hint(
|
|
_userMessages.cocoaPodsOutdated(currentVersionText, cocoaPodsRecommendedVersion.toString(), noCocoaPodsConsequence, cocoaPodsUpdateInstructions)));
|
|
}
|
|
return ValidationResult(status, messages);
|
|
}
|
|
}
|