hasPod static method

bool hasPod(
  1. String podfilePath,
  2. String podName
)

Return true if pod '<podName>' is declared anywhere in the Podfile.

This is a simple substring search, not a structural query. It matches any line that contains pod '<podName>', regardless of indentation, version constraint, or surrounding whitespace.

@param podfilePath Absolute or relative path to the Podfile. @param podName The CocoaPods pod name to search for, e.g. 'Firebase/Core'. @return true if found, false otherwise (including when the file does not exist).

Implementation

static bool hasPod(String podfilePath, String podName) {
  final file = File(podfilePath);
  if (!file.existsSync()) {
    return false;
  }
  return file.readAsStringSync().contains("pod '$podName'");
}