Skip to content

Commit e17bfb3

Browse files
committed
fix(ci): use Python to patch iOS deployment target in test workflow
1 parent e635a3c commit e17bfb3

1 file changed

Lines changed: 41 additions & 26 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -249,36 +249,51 @@ jobs:
249249

250250
- name: Set iOS minimum deployment target
251251
run: |
252-
PODFILE="ios/Podfile"
253-
if [ -f "$PODFILE" ]; then
254-
if grep -q "^platform :ios" "$PODFILE"; then
255-
sed -i '' "s/^platform :ios.*/platform :ios, '13.0'/" "$PODFILE"
256-
else
257-
sed -i '' "1a\
258-
platform :ios, '13.0'" "$PODFILE"
259-
fi
260-
if ! grep -q "IPHONEOS_DEPLOYMENT_TARGET" "$PODFILE"; then
261-
cat >> "$PODFILE" << 'RUBY'
262-
263-
post_install do |installer|
264-
installer.pods_project.targets.each do |target|
265-
target.build_configurations.each do |config|
252+
python3 - << 'PYEOF'
253+
import re, os
254+
255+
pbxproj = "ios/Runner.xcodeproj/project.pbxproj"
256+
if os.path.exists(pbxproj):
257+
content = open(pbxproj).read()
258+
patched = re.sub(
259+
r'IPHONEOS_DEPLOYMENT_TARGET = [\d.]+',
260+
'IPHONEOS_DEPLOYMENT_TARGET = 13.0',
261+
content
262+
)
263+
open(pbxproj, 'w').write(patched)
264+
print("✓ Patched Runner.xcodeproj deployment target to 13.0")
265+
else:
266+
print("⚠ Runner.xcodeproj not found — skipping")
267+
268+
podfile = "ios/Podfile"
269+
if os.path.exists(podfile):
270+
content = open(podfile).read()
271+
272+
if re.search(r"^platform :ios", content, re.MULTILINE):
273+
content = re.sub(
274+
r"^platform :ios.*",
275+
"platform :ios, '13.0'",
276+
content, flags=re.MULTILINE
277+
)
278+
else:
279+
content = "platform :ios, '13.0'\n" + content
280+
281+
if 'IPHONEOS_DEPLOYMENT_TARGET' not in content:
282+
content += """
283+
post_install do |installer|
284+
installer.pods_project.targets.each do |target|
285+
flutter_additional_ios_build_settings(target)
286+
target.build_configurations.each do |config|
266287
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
267288
end
268289
end
269290
end
270-
RUBY
271-
fi
272-
echo "✓ Podfile patched:"
273-
grep -E "platform|IPHONEOS" "$PODFILE" | head -5
274-
else
275-
echo "Podfile not found — will be created by flutter build"
276-
fi
277-
PBXPROJ="ios/Runner.xcodeproj/project.pbxproj"
278-
if [ -f "$PBXPROJ" ]; then
279-
sed -i '' 's/IPHONEOS_DEPLOYMENT_TARGET = [0-9.]*/IPHONEOS_DEPLOYMENT_TARGET = 13.0/g' "$PBXPROJ"
280-
echo "✓ Xcode project deployment target set to 13.0"
281-
fi
291+
"""
292+
open(podfile, 'w').write(content)
293+
print("✓ Patched Podfile platform to ios 13.0")
294+
else:
295+
print("⚠ Podfile not found — Flutter will generate it during build")
296+
PYEOF
282297
283298
- name: Build iOS
284299
run: |

0 commit comments

Comments
 (0)