Skip to content

Commit c0b1c0e

Browse files
committed
Fix Xcode Cloud translation resource build
1 parent afc517c commit c0b1c0e

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

build-qdomyos-zwift-Qt_5_15_2_for_iOS-Debug/ci_scripts/ci_pre_xcodebuild.sh

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,59 @@ if [[ -f "qdomyoszwift.xcodeproj/project.pbxproj" ]]; then
219219
sed -i '' 's|\(LIBRARY_SEARCH_PATHS = (\)|\1\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/Qt/labs/calendar,\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/Qt/labs/platform,\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/QtCharts,\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/QtWebView,\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/QtPositioning,\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/QtLocation,\n\t\t\t\t/tmp/Qt-5.15.2/ios/qml/QtMultimedia,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/platforms,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/webview,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/texttospeech,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/geoservices,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/sqldrivers,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/mediaservice,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/playlistformats,\n\t\t\t\t/tmp/Qt-5.15.2/ios/plugins/audio,|g' qdomyoszwift.xcodeproj/project.pbxproj
220220
echo "Added all necessary Qt library search paths"
221221

222+
# qmake now generates qrc_translations.cpp from translations.qrc, but this
223+
# committed Xcode project is restored after make. Add the generated resource
224+
# source back into the app target so Xcode Cloud compiles the translations.
225+
echo "Ensuring qrc_translations.cpp is included in Xcode project..."
226+
python3 - <<'PY'
227+
from pathlib import Path
228+
229+
project = Path("qdomyoszwift.xcodeproj/project.pbxproj")
230+
text = project.read_text()
231+
232+
if "qrc_translations.cpp in Compile Sources" in text:
233+
print("qrc_translations.cpp already present in Compile Sources")
234+
else:
235+
build_id = "AFC517CD7000000000000001"
236+
file_id = "AFC517CD7000000000000002"
237+
238+
replacements = [
239+
(
240+
"\t\t7352E0F0EE5366AC809B9D64 /* qrc_qml.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 49789298954386B0E136DA23 /* qrc_qml.cpp */; settings = {ATTRIBUTES = (); }; };\n",
241+
"\t\t7352E0F0EE5366AC809B9D64 /* qrc_qml.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 49789298954386B0E136DA23 /* qrc_qml.cpp */; settings = {ATTRIBUTES = (); }; };\n"
242+
f"\t\t{build_id} /* qrc_translations.cpp in Compile Sources */ = {{isa = PBXBuildFile; fileRef = {file_id} /* qrc_translations.cpp */; settings = {{ATTRIBUTES = (); }}; }};\n",
243+
),
244+
(
245+
"\t\t49789298954386B0E136DA23 /* qrc_qml.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = qrc_qml.cpp; path = \"/Volumes/workspace/repository/build-qdomyos-zwift-Qt_5_15_2_for_iOS-Debug/qrc_qml.cpp\"; sourceTree = \"<absolute>\"; };\n",
246+
"\t\t49789298954386B0E136DA23 /* qrc_qml.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = qrc_qml.cpp; path = \"/Volumes/workspace/repository/build-qdomyos-zwift-Qt_5_15_2_for_iOS-Debug/qrc_qml.cpp\"; sourceTree = \"<absolute>\"; };\n"
247+
f"\t\t{file_id} /* qrc_translations.cpp */ = {{isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = qrc_translations.cpp; path = \"/Volumes/workspace/repository/build-qdomyos-zwift-Qt_5_15_2_for_iOS-Debug/qrc_translations.cpp\"; sourceTree = \"<absolute>\"; }};\n",
248+
),
249+
(
250+
"\t\t\t\t49789298954386B0E136DA23 /* qrc_qml.cpp */,\n",
251+
f"\t\t\t\t49789298954386B0E136DA23 /* qrc_qml.cpp */,\n\t\t\t\t{file_id} /* qrc_translations.cpp */,\n",
252+
),
253+
(
254+
"\t\t\t\t7352E0F0EE5366AC809B9D64 /* qrc_qml.cpp in Compile Sources */,\n",
255+
f"\t\t\t\t7352E0F0EE5366AC809B9D64 /* qrc_qml.cpp in Compile Sources */,\n\t\t\t\t{build_id} /* qrc_translations.cpp in Compile Sources */,\n",
256+
),
257+
]
258+
259+
for needle, replacement in replacements:
260+
if needle not in text:
261+
raise SystemExit(f"Unable to patch Xcode project; anchor not found: {needle.strip()}")
262+
text = text.replace(needle, replacement, 1)
263+
264+
project.write_text(text)
265+
print("qrc_translations.cpp added to Xcode project")
266+
PY
267+
268+
if grep -q "qrc_translations.cpp in Compile Sources" qdomyoszwift.xcodeproj/project.pbxproj; then
269+
echo "SUCCESS: qrc_translations.cpp is included in Compile Sources"
270+
else
271+
echo "ERROR: qrc_translations.cpp was not added to Compile Sources"
272+
exit 1
273+
fi
274+
222275
# Verify the fix
223276
grep -c "libqtlabscalendarplugin.a" qdomyoszwift.xcodeproj/project.pbxproj && echo "qtlabscalendarplugin references found"
224277
grep -c "labs/calendar" qdomyoszwift.xcodeproj/project.pbxproj && echo "labs/calendar path references found"
@@ -351,4 +404,4 @@ else
351404
exit 1
352405
fi
353406

354-
echo "Pre-xcodebuild setup completed successfully"
407+
echo "Pre-xcodebuild setup completed successfully"

0 commit comments

Comments
 (0)