xworkmate-app/scripts/ensure-framework-dsyms.sh
Haitao Pan f8a5401963
[backport] fix(macos): workaround App Store Connect dSYM validation bug for App.framework (#63)
* fix(macos): workaround App Store Connect dSYM validation bug for App.framework

* trigger ci

* test: mock device and package plugins and increase timeout

- Increase sync loop timeout in thread workspace binding test to avoid flakiness
- Mock device_info and package_info plugins for gateway runtime tests
- Update pubspec.yaml version

* test: fix missing plugin in runtime_controllers_settings_account_test

* build: make sync-version.sh auto-increment build number

---------

Co-authored-by: Haitao Pan <manbuzhe2009@qq.com>
2026-06-30 10:38:44 +08:00

57 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Generate the dSYM that App Store validation expects for the vendored
# objective_c native-asset framework after Xcode/CocoaPods embed it.
if [[ "${CONFIGURATION:-}" != "Release" && "${CONFIGURATION:-}" != "Profile" ]]; then
exit 0
fi
if [[ -z "${FRAMEWORKS_FOLDER_PATH:-}" || -z "${TARGET_BUILD_DIR:-}" ]]; then
exit 0
fi
if [[ -z "${DWARF_DSYM_FOLDER_PATH:-}" ]]; then
exit 0
fi
frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
if [[ ! -d "${frameworks_dir}" ]]; then
exit 0
fi
mkdir -p "${DWARF_DSYM_FOLDER_PATH}"
for framework_path in "${frameworks_dir}"/*.framework; do
[[ -d "${framework_path}" ]] || continue
framework_name="$(basename "${framework_path}" .framework)"
binary_path="${framework_path}/${framework_name}"
[[ -f "${binary_path}" ]] || continue
[[ "${framework_name}" == "objective_c" ]] || continue
dsym_path="${DWARF_DSYM_FOLDER_PATH}/${framework_name}.framework.dSYM"
if [[ -d "${dsym_path}" ]]; then
continue
fi
if ! xcrun dwarfdump --uuid "${binary_path}" >/dev/null 2>&1; then
continue
fi
echo "Generating missing dSYM for ${framework_name}.framework"
if ! xcrun dsymutil "${binary_path}" -o "${dsym_path}" >/dev/null 2>&1; then
echo "warning: Failed to generate dSYM for ${framework_name}.framework" >&2
rm -rf "${dsym_path}" || true
fi
done
# Workaround for App Store Connect bug where it expects the DWARF file for App.framework to be named "A"
# because the binary is located at App.framework/Versions/A/App.
app_dwarf_dir="${DWARF_DSYM_FOLDER_PATH}/App.framework.dSYM/Contents/Resources/DWARF"
if [[ -d "${app_dwarf_dir}" && -f "${app_dwarf_dir}/App" && ! -f "${app_dwarf_dir}/A" ]]; then
echo "Applying workaround: Copying App DWARF file to A for App Store Connect validation"
cp "${app_dwarf_dir}/App" "${app_dwarf_dir}/A"
fi