|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +ipa_path="${1:-app/iosApp/iosApp.ipa}" |
| 6 | +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 7 | +required_symbols_file="$script_dir/../../app/iosApp/iosApp/CrashlyticsDynamicSymbols.txt" |
| 8 | + |
| 9 | +if [[ ! -f "$ipa_path" ]]; then |
| 10 | + echo "error: IPA not found: $ipa_path" >&2 |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +if [[ ! -f "$required_symbols_file" ]]; then |
| 15 | + echo "error: Required symbols file not found: $required_symbols_file" >&2 |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | +verification_dir="$(mktemp -d "${TMPDIR:-/tmp}/notedelight-ios-symbols.XXXXXX")" |
| 20 | +trap 'rm -rf -- "$verification_dir"' EXIT |
| 21 | + |
| 22 | +unzip -q "$ipa_path" -d "$verification_dir" |
| 23 | + |
| 24 | +payload_dir="$verification_dir/Payload" |
| 25 | +if [[ ! -d "$payload_dir" ]]; then |
| 26 | + echo "error: Payload directory not found in IPA: $ipa_path" >&2 |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +app_bundle="$(find "$payload_dir" -maxdepth 1 -type d -name '*.app' -print -quit)" |
| 31 | +if [[ -z "$app_bundle" ]]; then |
| 32 | + echo "error: App bundle not found in IPA: $ipa_path" >&2 |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | + |
| 36 | +executable_name="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$app_bundle/Info.plist")" |
| 37 | +app_executable="$app_bundle/$executable_name" |
| 38 | +if [[ ! -f "$app_executable" ]]; then |
| 39 | + echo "error: App executable not found: $app_executable" >&2 |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +exported_symbols="$verification_dir/exported-symbols.txt" |
| 44 | +xcrun dyld_info -exports "$app_executable" | |
| 45 | + awk 'NF == 2 && $1 ~ /^0x/ { print $2 }' > "$exported_symbols" |
| 46 | + |
| 47 | +required_symbols=() |
| 48 | +while IFS= read -r symbol; do |
| 49 | + if [[ -n "$symbol" ]]; then |
| 50 | + required_symbols+=("$symbol") |
| 51 | + fi |
| 52 | +done < "$required_symbols_file" |
| 53 | + |
| 54 | +if ((${#required_symbols[@]} == 0)); then |
| 55 | + echo "error: Required symbols file is empty: $required_symbols_file" >&2 |
| 56 | + exit 1 |
| 57 | +fi |
| 58 | + |
| 59 | +missing_symbols=0 |
| 60 | +for symbol in "${required_symbols[@]}"; do |
| 61 | + if ! grep -Fqx "$symbol" "$exported_symbols"; then |
| 62 | + echo "error: Required Crashlytics symbol is not exported: $symbol" >&2 |
| 63 | + missing_symbols=1 |
| 64 | + fi |
| 65 | +done |
| 66 | + |
| 67 | +if ((missing_symbols != 0)); then |
| 68 | + exit 1 |
| 69 | +fi |
| 70 | + |
| 71 | +echo "Verified Crashlytics symbols in $ipa_path" |
0 commit comments