#!/usr/bin/env bash # Test iOS su simulatore (arm64) — eseguire prima di ogni test su dispositivo / rilascio. # Uso: ./scripts/test_ios_simulator.sh # API=http://localhost:3000 ./scripts/test_ios_simulator.sh --e2e set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" IOS_DIR="$ROOT/native/ios" SIM_ID="${SIM_ID:-48A837E2-845E-4043-B168-B8D4FDCAAE21}" DERIVED="$IOS_DIR/build/DerivedData" RUN_E2E=false for arg in "$@"; do case "$arg" in --e2e) RUN_E2E=true ;; -h|--help) echo "Uso: $0 [--e2e]" echo " --e2e include anche scripts/e2e_ios_simulator.sh (richiede API Rails su localhost:3000)" exit 0 ;; esac done cd "$IOS_DIR" python3 generate_xcodeproj.py DEST="platform=iOS Simulator,id=$SIM_ID" ARCH_FLAGS=(ONLY_ACTIVE_ARCH=YES ARCHS=arm64 EXCLUDED_ARCHS=x86_64) echo "== Unit test iOS (simulatore arm64) ==" xcodebuild \ -project MatchLiveTv.xcodeproj \ -scheme MatchLiveTv \ -destination "$DEST" \ -derivedDataPath "$DERIVED" \ -configuration Debug \ "${ARCH_FLAGS[@]}" \ test 2>&1 | tee /tmp/matchlivetv-ios-test.log | tail -30 if grep -q "TEST SUCCEEDED" /tmp/matchlivetv-ios-test.log; then echo "== Unit test: OK ==" else echo "== Unit test: FALLITI (vedi /tmp/matchlivetv-ios-test.log) ==" >&2 exit 1 fi echo "== Build simulatore (smoke) ==" xcodebuild \ -project MatchLiveTv.xcodeproj \ -scheme MatchLiveTv \ -destination "$DEST" \ -derivedDataPath "$DERIVED" \ -configuration Debug \ "${ARCH_FLAGS[@]}" \ build 2>&1 | tail -5 APP="$DERIVED/Build/Products/Debug-iphonesimulator/MatchLiveTv.app" test -d "$APP" echo "== Build simulatore: OK ($APP) ==" if $RUN_E2E; then echo "== E2E API + simulatore ==" API="${API:-http://localhost:3000}" "$ROOT/scripts/e2e_ios_simulator.sh" fi echo "== test_ios_simulator.sh completato =="