• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'dart:async';
6
7import '../base/file_system.dart';
8import '../base/fingerprint.dart';
9import '../build_info.dart';
10import '../ios/xcodeproj.dart';
11import '../plugins.dart';
12import '../project.dart';
13import 'cocoapods.dart';
14
15/// For a given build, determines whether dependencies have changed since the
16/// last call to processPods, then calls processPods with that information.
17Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject,
18    String buildDirectory, BuildMode buildMode) async {
19  final FlutterProject project = xcodeProject.parent;
20  // Ensure that the plugin list is up to date, since hasPlugins relies on it.
21  refreshPluginsList(project);
22  if (!(hasPlugins(project) || (project.isModule && xcodeProject.podfile.existsSync()))) {
23    return;
24  }
25  // If the Xcode project, Podfile, or generated xcconfig have changed since
26  // last run, pods should be updated.
27  final Fingerprinter fingerprinter = Fingerprinter(
28    fingerprintPath: fs.path.join(buildDirectory, 'pod_inputs.fingerprint'),
29    paths: <String>[
30      xcodeProject.xcodeProjectInfoFile.path,
31      xcodeProject.podfile.path,
32      xcodeProject.generatedXcodePropertiesFile.path,
33    ],
34    properties: <String, String>{},
35  );
36
37  final bool didPodInstall = await cocoaPods.processPods(
38    xcodeProject: xcodeProject,
39    engineDir: flutterFrameworkDir(buildMode),
40    isSwift: xcodeProject.isSwift,
41    dependenciesChanged: !await fingerprinter.doesFingerprintMatch(),
42  );
43  if (didPodInstall) {
44    await fingerprinter.writeFingerprint();
45  }
46}
47