Files
2026-10-21 11:00:37 +08:00

45 lines
2.1 KiB
Bash
Raw Permalink 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 模拟器 —— 「选哪一台」的复杂度和灵活性都集中在这里。
#
echo '# Usage:'
echo 'bash ./emuBootIos.sh # 默认:Booted 优先,否则最新 iPhone'
echo 'bash ./emuBootIos.sh [email protected] # 短名@系统版本(推荐,跨机器通用)'
echo 'bash ./emuBootIos.sh [email protected] # iPhone 16 Pro / iOS 26.3'
echo 'bash ./emuBootIos.sh [email protected] # iPhone 16 / iOS 18.1'
echo 'bash ./emuBootIos.sh \"iPhone 17\" # 写机型全名(不带iOS版本取该机型最新)'
echo 'bash ./emuBootIos.sh FF429526-A7EE-… # 直接给 UDID'
echo '[email protected] bash ./emuBootIos.sh # 用环境变量改默认'
echo
echo '# 短名: ipxr/ipxs、ip11~ip17(各代含 pro/plus/mini/pc/pm/air 后缀)(见 node_modules/wo_scripts/emuResolveIos.js;旧机型需先装对应 iOS runtime)'
echo '# 也可以在 package.json 的 config 里加("ipad": "iPad Pro 13-inch (M4)")'
echo
echo 'npm run app-ios-run # 跑 App(默认打当前已启动的那台,纯 booted)'
echo '[email protected] npm run app-ios-run # 临时指定某台(flutter 会自己 boot 它)'
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
spec="${1:-${EMU:-}}"
udid="$(node "${SCRIPT_DIR}/emuResolveIos.js" "${spec}")"
echo "▶ 模拟器 ${spec:-默认} → ${udid}"
if xcrun simctl boot "${udid}" 2>/dev/null; then
echo "✅ 已启动"
else
echo "(已在运行,跳过 boot)"
fi
# Xcode 27 起不再随附 Simulator.app(simctl 独立工作);模拟器 GUI 改由
# DeviceHub(Xcode.app/Contents/Applications/DeviceHub.app)承担——有就开它,
# 没有就跳过(flutter run 也会自己唤起模拟器窗口)。
SIM_APP="$(xcode-select -p)/Applications/Simulator.app"
if [ -d "$SIM_APP" ]; then
open "$SIM_APP"
else
echo "(本机 Xcode 无 Simulator.app(Xcode 27+ 已移除),跳过开 GUI)"
echo " 看模拟器界面:open -b com.apple.dt.Devices # DeviceHub"
echo " 或直接 flutter run,会自动把模拟器窗口带到前台"
fi
xcrun simctl list devices booted