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

Code before:

    if (result.exitCode != 0) {
      invalidatePodInstallOutput(xcodeProject);
      await _diagnosePodInstallFailure(result, xcodeProject);
      throwToolExit('Error running pod install');
    } else if (xcodeProject.podfileLock.existsSync()) {
      // Even if the Podfile.lock didn't change, update its modified date to now
      // so Podfile.lock is newer than Podfile.
      _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 `plguin_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;
          }

Review comment (suggestion):
```suggestion
      // Example: Unable to find a specification for `plugin_a` depended upon by `plugin_b`
```

Code after:

    if (result.exitCode != 0) {
      invalidatePodInstallOutput(xcodeProject);
      await _diagnosePodInstallFailure(result, xcodeProject);
      throwToolExit('Error running pod install');
    } else if (xcodeProject.podfileLock.existsSync()) {
      // Even if the Podfile.lock didn't change, update its modified date to now
      // so Podfile.lock is newer than Podfile.
      _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;