cocoapod_utils.dart 1.62 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8
// 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/fingerprint.dart';
import '../build_info.dart';
9
import '../globals.dart' as globals;
10 11 12 13 14 15
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.
16
Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject, String buildDirectory, BuildMode buildMode) async {
17 18
  final FlutterProject project = xcodeProject.parent;
  // Ensure that the plugin list is up to date, since hasPlugins relies on it.
19
  await refreshPluginsList(project);
20 21 22 23 24 25
  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(
26
    fingerprintPath: globals.fs.path.join(buildDirectory, 'pod_inputs.fingerprint'),
27 28 29 30 31 32 33 34
    paths: <String>[
      xcodeProject.xcodeProjectInfoFile.path,
      xcodeProject.podfile.path,
      xcodeProject.generatedXcodePropertiesFile.path,
    ],
    properties: <String, String>{},
  );

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