Repository: flutter/flutter
File: packages/flutter_tools/lib/src/macos/cocoapods.dart (Dart)

Code before:
      _processManager.runSync(<String>[
        'touch',
        xcodeProject.podfileLock.path,
      ], workingDirectory: _fileSystem.path.dirname(xcodeProject.podfile.path));
    }
  }

  Future<void> _diagnosePodInstallFailure(
    ProcessResult result,
    XcodeBasedProject xcodeProject,
  ) async {
    final Object? stdout = result.stdout;
    final Object? stderr = result.stderr;
    if (stdout is! String || stderr is! String) {
      return;
    }
    if (stdout.contains('Unable to find a specification for')) {
      // Example: Unable to find a specification for `plugin_a` depended upon by `plugin_b`
      final pattern = RegExp(r'Unable to find a specification for `(.*)` depended upon by `(.*)`');
      final Iterable<RegExpMatch> matches = pattern.allMatches(stdout);
      for (final match in matches) {
        final String? missingPlugin = match.group(1);
        final String? requiringPlugin = match.group(2);
        if (missingPlugin != null && requiringPlugin != null) {
          final List<Plugin> plugins = await findPlugins(xcodeProject.parent);
          final bool missingPluginSupportsSwiftPM = plugins.any(
            (plugin) =>
                plugin.name == missingPlugin &&
                plugin.supportSwiftPackageManagerForPlatform(
                  _fileSystem,
                  xcodeProject.pluginConfigKey,
                ),
          );
          if (missingPluginSupportsSwiftPM) {
            _logger.printError(
              'Error: A dependency conflict has occurred because $requiringPlugin uses CocoaPods while '
              '$missingPlugin uses Swift Package Manager. Please contact the $requiringPlugin '
              'maintainers to request Swift Package Manager adoption.\n\n'
              '$kDisableSwiftPMInstructions',
              emphasis: true,
            );
            return;
          }
        }
      }
    }
    if (stdout.contains('out-of-date source repos')) {
      _logger.printError(
        "Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.\n"
        'To update the CocoaPods specs, run:\n'
        '  pod repo update\n',

Review comment (suggestion):
Shouldn't we also make sure SwiftPM is enabled (at the tool and project level)? If someone somehow manages to get this CP error when they don't have SwiftPM enabled, we don't want to given this error message.

Code after:
      _processManager.runSync(<String>[
        'touch',
        xcodeProject.podfileLock.path,
      ], workingDirectory: _fileSystem.path.dirname(xcodeProject.podfile.path));
    }
  }

  Future<void> _diagnosePodInstallFailure(
    ProcessResult result,
    XcodeBasedProject xcodeProject,
  ) async {
    final Object? stdout = result.stdout;
    final Object? stderr = result.stderr;
    if (stdout is! String || stderr is! String) {
      return;
    }
    final String? conflict = await _pluginDependencyManagerConflictError(stdout, xcodeProject);
    if (conflict != null) {
      _logger.printError(conflict, emphasis: true);
      return;
    }
    if (stdout.contains('out-of-date source repos')) {
      _logger.printError(
        "Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.\n"
        'To update the CocoaPods specs, run:\n'
        '  pod repo update\n',
        emphasis: true,
      );
    } else if ((_isFfiX86Error(stdout) || _isFfiX86Error(stderr)) &&
        _operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64) {
      // https://github.com/flutter/flutter/issues/70796
      _analytics.send(Event.appleUsageEvent(workflow: 'pod-install-failure', parameter: 'arm-ffi'));
      _logger.printError(
        'Error: To set up CocoaPods for ARM macOS, run:\n'
        '  sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc\n',
        emphasis: true,
      );
    } else if (stdout.contains('required a higher minimum deployment target')) {
      final ({String failingPod, String sourcePlugin, String podPluginSubdir})? podInfo =
          _parseMinDeploymentFailureInfo(stdout);
      if (podInfo != null) {
        final Directory symlinksDir;
        final String podPlatformString;
        final String platformName;
        final String docsLink;
        if (xcodeProject is IosProject) {
          symlinksDir = xcodeProject.symlinks;
          podPlatformString = 'ios';
          platformName = 'iOS';
          docsLink = 'https://flutter.dev/to/ios-deploy';
        } else if (xcodeProject is MacOSProject) {