cocoapod_utils.dart 1.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
// Copyright 2019 The Chromium 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 'dart:async';

import '../base/file_system.dart';
import '../base/fingerprint.dart';
import '../build_info.dart';
import '../ios/xcodeproj.dart';
import '../plugins.dart';
import '../project.dart';
import 'cocoapods.dart';

/// For a given build, determines whether dependencies have changed since the
/// last call to processPods, then calls processPods with that information.
Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject,
    String buildDirectory, BuildMode buildMode) async {
  final FlutterProject project = xcodeProject.parent;
  // Ensure that the plugin list is up to date, since hasPlugins relies on it.
  refreshPluginsList(project);
  if (!(hasPlugins(project) || (project.isModule && xcodeProject.podfile.existsSync()))) {
    return;
  }
  // If the Xcode project, Podfile, or generated xcconfig have changed since
  // last run, pods should be updated.
  final Fingerprinter fingerprinter = Fingerprinter(
    fingerprintPath: fs.path.join(buildDirectory, 'pod_inputs.fingerprint'),
    paths: <String>[
      xcodeProject.xcodeProjectInfoFile.path,
      xcodeProject.podfile.path,
      xcodeProject.generatedXcodePropertiesFile.path,
    ],
    properties: <String, String>{},
  );

  final bool didPodInstall = await cocoaPods.processPods(
    xcodeProject: xcodeProject,
    engineDir: flutterFrameworkDir(buildMode),
    isSwift: xcodeProject.isSwift,
41
    dependenciesChanged: !fingerprinter.doesFingerprintMatch(),
42 43
  );
  if (didPodInstall) {
44
    fingerprinter.writeFingerprint();
45 46
  }
}