Skip to content

Commit 639ebff

Browse files
committed
ci(cordova-ios): fix Cordova iOS build in CI; update patch-ios.sh and remove Capacitor-specific CI patching
1 parent 469fc00 commit 639ebff

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ jobs:
6565
ionic cordova platform add ios@latest
6666
# run the patch script from the repository root to adjust generated iOS files in CI
6767
bash ../scripts/patch-ios.sh platforms/ios
68+
# verify CocoaPods and ensure specs are up-to-date (redundant with script but safe)
69+
pod --version || true
70+
(cd platforms/ios && pod install --repo-update) || true
6871
# build and instruct Cordova/Xcode to use the xcconfig the script creates
69-
ionic cordova build ios --no-interactive -- --buildFlag="-xcconfig platforms/ios/xcconfigs/ci-overrides.xcconfig" --buildFlag="-sdk iphonesimulator"
72+
ionic cordova build ios --no-interactive -- \
73+
--buildFlag="-xcconfig platforms/ios/xcconfigs/ci-overrides.xcconfig" \
74+
--buildFlag="-sdk iphonesimulator" \
75+
--buildFlag="-destination generic/platform=iOS Simulator"
7076
7177
test-capacitor:
7278
name: Test (Capacitor)
@@ -121,6 +127,4 @@ jobs:
121127
cd testapp
122128
ionic cap add ios
123129
npx cap sync ios
124-
# run the patch script to adjust generated Capacitor iOS files in CI
125-
bash ../scripts/patch-ios.sh ios
126-
xcodebuild -workspace ios/App/App.xcworkspace -scheme App -sdk iphonesimulator -configuration Debug build -xcconfig ios/xcconfigs/ci-overrides.xcconfig
130+
xcodebuild -workspace ios/App/App.xcworkspace -scheme App -sdk iphonesimulator -configuration Debug build

scripts/patch-ios.sh

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
set -euo pipefail
33

44
# Usage: scripts/patch-ios.sh [target-dir ...]
5-
# If no targets provided, it will attempt both 'platforms/ios' (Cordova) and 'ios' (Capacitor).
65

76
if [[ $# -gt 0 ]]; then
87
TARGETS=("$@")
98
else
10-
TARGETS=("platforms/ios" "ios")
9+
TARGETS=("platforms/ios")
1110
fi
1211

1312
# Helper for portable sed - macOS needs -i ''
@@ -31,6 +30,10 @@ for BASE in "${TARGETS[@]}"; do
3130
if [[ -f "$PBX_PATH" ]]; then
3231
echo " - Updating deployment target in ${PBX_PATH}"
3332
"${SED_INPLACE[@]}" "s/IPHONEOS_DEPLOYMENT_TARGET = [0-9]\{1,2\}\.[0-9]\{1,2\} *;/IPHONEOS_DEPLOYMENT_TARGET = 13.0;/g" "$PBX_PATH" || true
33+
34+
echo " - Ensuring simulator excludes arm64 in ${PBX_PATH}"
35+
# Add EXCLUDED_ARCHS for simulator to avoid arm64 issues on some pods
36+
"${SED_INPLACE[@]}" "/buildSettings = {$/a\\ EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64;" "$PBX_PATH" || true
3437
else
3538
echo " - ${PBX_PATH} not found, skipping deployment target patch"
3639
fi
@@ -59,15 +62,42 @@ for BASE in "${TARGETS[@]}"; do
5962
# 3) Ensure Podfile platform is at least 13.0
6063
if [[ -f "$PODFILE_PATH" ]]; then
6164
echo " - Ensuring Podfile platform is at least iOS 13.0"
62-
awk '
63-
{
64-
if ($0 ~ /^\s*platform\s*:\s*.*ios/) {
65-
print "platform :ios, '\''13.0'\''"
66-
} else {
67-
print
65+
if grep -q "^\s*platform\s*:\s*.*ios" "$PODFILE_PATH"; then
66+
awk '
67+
{
68+
if ($0 ~ /^\s*platform\s*:\s*.*ios/) {
69+
print "platform :ios, '\''13.0'\''"
70+
} else {
71+
print
72+
}
6873
}
69-
}
70-
' "$PODFILE_PATH" > "${PODFILE_PATH}.patched" && mv "${PODFILE_PATH}.patched" "$PODFILE_PATH" || true
74+
' "$PODFILE_PATH" > "${PODFILE_PATH}.patched" && mv "${PODFILE_PATH}.patched" "$PODFILE_PATH" || true
75+
else
76+
# Prepend platform line if missing
77+
{
78+
echo "platform :ios, '13.0'"
79+
cat "$PODFILE_PATH"
80+
} > "${PODFILE_PATH}.patched" && mv "${PODFILE_PATH}.patched" "$PODFILE_PATH"
81+
fi
82+
83+
# Ensure pods build with at least iOS 13.0 (add post_install if missing)
84+
if ! grep -q "post_install" "$PODFILE_PATH"; then
85+
cat >> "$PODFILE_PATH" <<'PODPATCH'
86+
post_install do |installer|
87+
installer.pods_project.targets.each do |target|
88+
target.build_configurations.each do |config|
89+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
90+
end
91+
end
92+
end
93+
PODPATCH
94+
fi
95+
96+
echo " - Running CocoaPods install with repo update"
97+
(
98+
cd "$BASE"
99+
pod install --repo-update --silent || pod install --repo-update || true
100+
)
71101
else
72102
echo " - ${PODFILE_PATH} not found, skipping Podfile patch"
73103
fi
@@ -76,6 +106,8 @@ for BASE in "${TARGETS[@]}"; do
76106
mkdir -p "$XC_CONFIG_DIR"
77107
cat > "$XC_CONFIG_PATH" <<'XC'
78108
HEADER_SEARCH_PATHS = $(inherited) $(DERIVED_FILE_DIR)/GeneratedModuleMaps-iphonesimulator
109+
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64
110+
ONLY_ACTIVE_ARCH = YES
79111
XC
80112
echo " - Created ${XC_CONFIG_PATH}"
81113

0 commit comments

Comments
 (0)