1. 查看模拟器的命令
在 iOS 开发中,使用 Xcode 自带的 xcrun
和 xcodebuild
命令可以查看和运行 iOS 模拟器设备。以下是相关命令:
1. 查看可用的模拟器设备
xcrun simctl list devices
或者:
xcrun simctl list
这将列出所有可用的 iOS 模拟器设备,包括它们的 UDID(唯一标识符)和当前状态(Booted 代表正在运行)。
2. 启动指定的模拟器
xcrun simctl boot "iPhone 15 Pro"
如果你知道 UDID,可以这样:
xcrun simctl boot <设备UDID>
3. 运行 iOS 模拟器
如果模拟器未启动,可以使用:
open -a Simulator
或者:
xcrun simctl boot "iPhone 15 Pro" && open -a Simulator
4. 直接运行 App 到模拟器
如果你想把 app 运行到模拟器上,可以使用:
xcrun simctl install booted <App路径>
xcrun simctl launch booted <App的 Bundle Identifier>
示例:
xcrun simctl install booted /path/to/your.app
xcrun simctl launch booted com.yourcompany.yourapp
5. 关闭模拟器
xcrun simctl shutdown all
或者关闭指定设备:
xcrun simctl shutdown <设备UDID>
Last updated