Skip to content

Commit 095690a

Browse files
russellwheatleymikehardy
authored andcommitted
ci(ios): extract shared, grep-verified Podfile dep-resolution patch script
The "Configure Dependency Resolution Mode" step was duplicated verbatim across the ios and ios-release-archive jobs in tests_e2e_ios.yml, and its plain sed patches silently no-op on a Podfile wording change instead of failing loudly. Extract both real patches (linkage swap, $RNFirebaseDisableSPM prepend) into .github/workflows/scripts/configure-ios-dep-resolution.sh, with a grep assertion after each patch, and drop the third sed line (/SWIFT_ENABLE_EXPLICIT_MODULES/d) entirely -- that setting moved into firebase_spm.rb's Ruby post_install hook and is dead code in the Podfile today.
1 parent 72b5561 commit 095690a

2 files changed

Lines changed: 67 additions & 22 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# Configure tests/ios/Podfile for the CI dependency-resolution matrix leg (spm vs cocoapods).
3+
# Shared by both "Configure Dependency Resolution Mode" steps in tests_e2e_ios.yml
4+
# (the `ios` job and the `ios-release-archive` job) so the two legs can't drift apart.
5+
#
6+
# Usage: configure-ios-dep-resolution.sh <spm|cocoapods> [podfile-dir]
7+
# podfile-dir defaults to tests/ios, since every caller in tests_e2e_ios.yml runs
8+
# with the workflow's default working directory (the repo root).
9+
#
10+
# spm mode is a no-op: the checked-in Podfile already resolves Firebase via SPM
11+
# (dynamic linkage, no $RNFirebaseDisableSPM flag -- see packages/app/firebase_spm.rb).
12+
#
13+
# cocoapods mode patches the Podfile to force static linkage and disable SPM
14+
# resolution. Each patch is grep-verified immediately after being applied, so a future
15+
# change to the Podfile's wording (e.g. reformatting `linkage = 'dynamic'`) fails this
16+
# script loudly instead of silently leaving the "cocoapods" CI leg testing the SPM path
17+
# a second time.
18+
set -euo pipefail
19+
20+
log_dep_resolution() {
21+
echo "[dep-resolution] $*"
22+
}
23+
24+
configure_cocoapods_mode() {
25+
local podfile_dir="$1"
26+
local podfile="${podfile_dir}/Podfile"
27+
28+
log_dep_resolution "configuring CocoaPods-only mode (disabling SPM) in ${podfile}"
29+
30+
sed -i '' "s/^linkage = 'dynamic'/linkage = 'static'/" "$podfile"
31+
grep -q "^linkage = 'static'" "$podfile" || {
32+
log_dep_resolution "ERROR: expected \"linkage = 'static'\" in ${podfile} after sed, but it was not found -- has the Podfile's linkage line wording changed?"
33+
exit 1
34+
}
35+
36+
printf '%s\n' '$RNFirebaseDisableSPM = true' | cat - "$podfile" > "${podfile}.tmp" && mv "${podfile}.tmp" "$podfile"
37+
local first_line
38+
first_line="$(head -n 1 "$podfile")"
39+
[[ "$first_line" == '$RNFirebaseDisableSPM = true' ]] || {
40+
log_dep_resolution "ERROR: expected the first line of ${podfile} to be '\$RNFirebaseDisableSPM = true' after prepend, got: ${first_line}"
41+
exit 1
42+
}
43+
44+
log_dep_resolution "Podfile configured for CocoaPods-only mode"
45+
}
46+
47+
configure_spm_mode() {
48+
log_dep_resolution "using default SPM mode (dynamic linkage)"
49+
}
50+
51+
MODE="${1:-}"
52+
PODFILE_DIR="${2:-tests/ios}"
53+
54+
case "$MODE" in
55+
cocoapods)
56+
configure_cocoapods_mode "$PODFILE_DIR"
57+
;;
58+
spm)
59+
configure_spm_mode
60+
;;
61+
*)
62+
log_dep_resolution "ERROR: unrecognized dependency-resolution mode '${MODE}' (expected 'spm' or 'cocoapods')"
63+
exit 1
64+
;;
65+
esac

.github/workflows/tests_e2e_ios.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,7 @@ jobs:
263263
restore-keys: ${{ runner.os }}-${{ matrix.dep-resolution }}-ios-pods-v3
264264

265265
- name: Configure Dependency Resolution Mode
266-
run: |
267-
if [[ "${{ matrix.dep-resolution }}" == "cocoapods" ]]; then
268-
echo "Configuring CocoaPods-only mode (disabling SPM)"
269-
cd tests/ios
270-
sed -i '' "s/^linkage = 'dynamic'/linkage = 'static'/" Podfile
271-
printf '%s\n' '$RNFirebaseDisableSPM = true' | cat - Podfile > Podfile.tmp && mv Podfile.tmp Podfile
272-
sed -i '' "/SWIFT_ENABLE_EXPLICIT_MODULES/d" Podfile
273-
echo "Podfile configured for CocoaPods-only mode"
274-
else
275-
echo "Using default SPM mode (dynamic linkage)"
276-
fi
266+
run: .github/workflows/scripts/configure-ios-dep-resolution.sh "${{ matrix.dep-resolution }}"
277267

278268
- name: Pod Install
279269
# https://github.com/nick-fields/retry/releases
@@ -663,17 +653,7 @@ jobs:
663653
restore-keys: ${{ runner.os }}-${{ matrix.dep-resolution }}-ios-pods-v3
664654

665655
- name: Configure Dependency Resolution Mode
666-
run: |
667-
if [[ "${{ matrix.dep-resolution }}" == "cocoapods" ]]; then
668-
echo "Configuring CocoaPods-only mode (disabling SPM)"
669-
cd tests/ios
670-
sed -i '' "s/^linkage = 'dynamic'/linkage = 'static'/" Podfile
671-
printf '%s\n' '$RNFirebaseDisableSPM = true' | cat - Podfile > Podfile.tmp && mv Podfile.tmp Podfile
672-
sed -i '' "/SWIFT_ENABLE_EXPLICIT_MODULES/d" Podfile
673-
echo "Podfile configured for CocoaPods-only mode"
674-
else
675-
echo "Using default SPM mode (dynamic linkage)"
676-
fi
656+
run: .github/workflows/scripts/configure-ios-dep-resolution.sh "${{ matrix.dep-resolution }}"
677657

678658
- name: Pod Install
679659
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0

0 commit comments

Comments
 (0)