Files
life-echo/app-expo/scripts/ios-prebuild.sh
Kevin 6d281c92a5 feat(app-expo): env variants, local iOS prebuild, and About diagnostics
Align staging/production builds with APP_VARIANT bundle IDs, allow staging HTTP on iOS, add ios-prebuild scripts for TestFlight, and show connected API URL on About for non-production builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 15:43:16 +08:00

68 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 本机 iOS Release切换 env → expo prebuild → 打开 Xcode 打 Archive 上传 TestFlight。
#
# 用法(在仓库任意目录):
# app-expo/scripts/ios-prebuild.sh staging
# app-expo/scripts/ios-prebuild.sh production
#
# 或通过 npm在 app-expo 目录):
# npm run ios:prebuild:staging
# npm run ios:prebuild:production
#
# Xcode 内后续步骤(脚本不会自动执行):
# 1. 选 Any iOS Device或 Generic iOS Device
# 2. Product → Archive
# 3. Distribute App → App Store Connect → Upload进入 TestFlight
set -euo pipefail
ENV="${1:-}"
if [[ -z "$ENV" ]]; then
echo "Usage: $(basename "$0") <staging|production|development>" >&2
exit 1
fi
case "$ENV" in
staging | production | development) ;;
*)
echo "Unknown environment: $ENV (expected staging, production, or development)" >&2
exit 1
;;
esac
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
echo "==> Switching to .env.${ENV}"
npm run use-env -- "$ENV"
echo "==> expo prebuild --platform ios --clean"
npx expo prebuild --platform ios --clean
shopt -s nullglob
WORKSPACES=(ios/*.xcworkspace)
shopt -u nullglob
if [[ ${#WORKSPACES[@]} -eq 0 ]]; then
echo "No ios/*.xcworkspace found after prebuild." >&2
exit 1
fi
if [[ ${#WORKSPACES[@]} -gt 1 ]]; then
echo "Multiple workspaces found; opening the first: ${WORKSPACES[0]}" >&2
fi
echo "==> Opening ${WORKSPACES[0]}"
open "${WORKSPACES[0]}"
cat <<EOF
Done. In Xcode:
• Select "Any iOS Device" (or a connected device)
• Product → Archive
• Window → Organizer → Distribute App → App Store Connect
Environment: ${ENV}
API URL: $(grep -E '^EXPO_PUBLIC_API_URL=' .env 2>/dev/null | cut -d= -f2- || echo '(see .env)')
EOF