cocoapod_utils.dart 1.63 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../base/fingerprint.dart';
import '../build_info.dart';
7
import '../globals.dart' as globals;
8 9 10 11 12 13
import '../ios/xcodeproj.dart';
import '../plugins.dart';
import '../project.dart';

/// For a given build, determines whether dependencies have changed since the
/// last call to processPods, then calls processPods with that information.
14 15 16 17 18
Future<void> processPodsIfNeeded(
  XcodeBasedProject xcodeProject,
  String buildDirectory,
  BuildMode buildMode,
) async {
19 20
  final FlutterProject project = xcodeProject.parent;
  // Ensure that the plugin list is up to date, since hasPlugins relies on it.
21
  await refreshPluginsList(project);
22 23 24 25 26 27
  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(
28
    fingerprintPath: globals.fs.path.join(buildDirectory, 'pod_inputs.fingerprint'),
29 30 31 32 33
    paths: <String>[
      xcodeProject.xcodeProjectInfoFile.path,
      xcodeProject.podfile.path,
      xcodeProject.generatedXcodePropertiesFile.path,
    ],
34 35
    fileSystem: globals.fs,
    logger: globals.logger,
36 37
  );

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