Files
telegram-tui/scripts/run-ios-simulator-app.sh
2026-05-20 22:26:53 +03:00

36 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
if [[ -z "${DEVELOPER_DIR:-}" && -d /Applications/Xcode.app/Contents/Developer ]]; then
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
fi
configuration="${IOS_CONFIGURATION:-Debug}"
derived_data="${IOS_DERIVED_DATA:-/private/tmp/tele-tui-ios-derived-data}"
bundle_id="${IOS_BUNDLE_ID:-dev.teletui.TeleTuiIOSApp}"
app_path="${derived_data}/Build/Products/${configuration}-iphonesimulator/TeleTuiIOSApp.app"
"${repo_root}/scripts/build-ios-simulator-app.sh"
simulator_udid="${IOS_SIMULATOR_UDID:-}"
if [[ -z "${simulator_udid}" ]]; then
simulator_udid="$(xcrun simctl list devices available | awk -F '[()]' '/iPhone/ { print $2; exit }')"
fi
if [[ -z "${simulator_udid}" ]]; then
printf 'No available iPhone simulator found. Run scripts/check-ios-prereqs.sh for details.\n' >&2
exit 1
fi
if ! xcrun simctl list devices "${simulator_udid}" | grep -q 'Booted'; then
xcrun simctl boot "${simulator_udid}"
fi
xcrun simctl bootstatus "${simulator_udid}" -b
xcrun simctl install "${simulator_udid}" "${app_path}"
xcrun simctl launch "${simulator_udid}" "${bundle_id}"
printf 'Launched %s on simulator %s.\n' "${bundle_id}" "${simulator_udid}"