Module: CocoaPodsAmicable::TargetIntegratorMixin

Defined in:
lib/cocoapods_amicable.rb

Instance Method Summary collapse

Instance Method Details

#add_check_manifest_lock_script_phaseObject


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
41
42
43
44
45
46
# File 'lib/cocoapods_amicable.rb', line 5

def add_check_manifest_lock_script_phase
  podfile = target.target_definition.podfile
  return super unless podfile.plugins.key?('cocoapods-amicable')

  phase_name = Pod::Installer::UserProjectIntegrator::TargetIntegrator::CHECK_MANIFEST_PHASE_NAME
  native_targets.each do |native_target|
    phase = Pod::Installer::UserProjectIntegrator::TargetIntegrator.create_or_update_shell_script_build_phase(native_target,
                                                                                                              Pod::Installer::UserProjectIntegrator::TargetIntegrator::BUILD_PHASE_PREFIX + phase_name)
    native_target.build_phases.unshift(phase).uniq! unless native_target.build_phases.first == phase

    phase.shell_script = <<-SH
set -e
set -u
set -o pipefail

fail() {
# print error to STDERR
echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." [email protected] >&2
exit 1
}

diff -q "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null || fail "The manifest in the sandbox differs from your lockfile."

if [ -f "${PODS_ROOT}/Podfile.sha1" ]; then
(cd "${PODS_PODFILE_DIR_PATH}" && shasum --algorithm 1 --status --check "${PODS_ROOT}/Podfile.sha1") || fail "Your Podfile has been changed since the last time you ran 'pod install'."
fi

# This output is used by Xcode 'outputs' to avoid re-running this script phase.
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"
          SH

    phase.input_paths = %w[
      ${PODS_PODFILE_DIR_PATH}/Podfile.lock
      ${PODS_ROOT}/Manifest.lock
      ${PODS_ROOT}/Podfile.sha1
    ]
    if name = podfile.defined_in_file && podfile.defined_in_file.basename
      phase.input_paths << "${PODS_PODFILE_DIR_PATH}/#{name}"
    end
    phase.output_paths = [target.check_manifest_lock_script_output_file_path]
  end
end