add emu*.sh to boot ios emulator by short names

This commit is contained in:
luk
2026-10-07 07:28:21 +08:00
parent 4645729e64
commit 093663f62d
7 changed files with 611 additions and 2 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# 启动 iOS 模拟器 —— 「选哪一台」的复杂度和灵活性都集中在这里。
#
# npm run app-ios-boot # 默认 [email protected]
# npm run app-ios-boot -- [email protected] # 短名@系统版本(推荐,跨机器通用)
# npm run app-ios-boot -- [email protected] # iPhone 16 Pro / iOS 26.3
# npm run app-ios-boot -- [email protected] # iPhone 16 / iOS 18.1
# npm run app-ios-boot -- "iPhone [email protected]" # 写机型全名也行
# npm run app-ios-boot -- FF429526-A7EE-… # 直接给 UDID
# [email protected] npm run app-ios-boot # 用环境变量改默认
#
# 短名表见 scripts/emuResolveIos.js 的 builtinAlias(ip16 / ip16plus / ip16pro / ip16pm),
# 也可以在 package.json 的 config 里加("ipad": "iPad Pro 13-inch (M4)")。
#
# 跑 App 永远打「当前已启动的那台」(纯 booted 语义):
# npm run app-ios-emu-run-local
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
open "$(xcode-select -p)/Applications/Simulator.app"
xcrun simctl list devices booted