Files
wo_scripts/emuBootIos.sh
T
lukandAtomCode 75ae4e9e22 update: 同步 emu* 脚本至 einz 最新版
- emuResolveIos.js:裸跑时 Booted 优先、否则取系统版本最高的 iPhone;
  EMU 环境变量最高优先;短名表扩至 ip17 系列;修复 rootDir 指向错误
  导致项目 config 永远读不到的问题
- emuBootIos.sh:Xcode 27+ 不再随附 Simulator.app,检测后跳过并提示
  DeviceHub

来源:~/einz/scripts/(拷贝后 einz 侧持续演进,此处为落后快照)

Co-Authored-By: AtomCode (glm5.3-flash) <[email protected]>
2026-10-16 22:02:16 +08:00

42 lines
1.8 KiB
Bash
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 模拟器 —— 「选哪一台」的复杂度和灵活性都集中在这里。
#
# 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
# 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