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>
This commit is contained in:
Kevin
2026-05-19 15:43:16 +08:00
parent 3921c5ec24
commit 6d281c92a5
13 changed files with 275 additions and 18 deletions

View File

@@ -0,0 +1,67 @@
#!/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

View File

@@ -2,7 +2,7 @@
* 将 app-expo/.env.<name> 复制为 .env供 Metro/Expo 读取 EXPO_PUBLIC_*。
*
* 参数 name → 源文件:
* development → .env.development本地默认:npm start / prestart
* development → .env.development仓库已提交;npm start / prestart 默认
* staging → .env.staging
* production → .env.production
*