iOS模拟器命令xcrun simctl系列(自动化测试)

本文详细介绍了使用Xcode命令行工具进行iOS模拟器的各种操作,包括安装、启动、关闭、重置模拟器,以及在模拟器上安装、运行、卸载应用,截图、录屏和查看日志等高级功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 列出安装的可用的模拟器: xcrun instruments -s

【如:iPhone 5s (9.0) [00AB3BB6-C5DC-45C7-804F-6B88F57C2AFF] (Simulator)】

1. 查看已安装的模拟器: ios-sim showdevicetypes

【如:iPhone-6s, 11.1
iPhone-6s, 10.0
iPhone-6s, 9.0
iPhone-6s, 11.2
iPhone-6s, 10.1
iPhone-6s, 9.2】

1. 查看已安装的模拟器: xcrun simctl list

【如:
-- iOS 11.3 --
iPhone 5s (9ABF3B1A-4A86-4BAC-BBB2-5D63CC30F0DE) (Shutdown)】
查看启动的模拟器 xcrun simctl list | grep Booted

2. 开启上面列表中指定的模拟器: xcrun instruments -w "iPhone 8(11.2)"

2. 开启指定的模拟器: xcrun simctl boot udid

3. 关掉模拟器: xcrun simctl shutdown udid

关掉所有打开的模拟器: xcrun simctl shutdown all

4. 重置模拟器(清除模拟器的数据和设置)xcrun simctl erase udid

5. 安装指定app: xcrun simctl install booted <app路径>

多设备时:xcrun simctl install <device> <app路径> 

5. 安装指定app: ios-sim launch /Users/nali/Desktop/ting.app --devicetypeid iPhone-X, 11.2

6. 运行指定的app: xcrun simctl launch booted <bundle identifier>

多设备时:xcrun simctl launch <device> <bundle identifier>

7. 关闭已经打开的应用: xcrun simctl terminate booted <bundle identifer>

多设备时:xcrun simctl terminate <device> <bundle identifier>

8. 卸载指定应用: xcrun simctl uninstall booted <bundle identifer>

多设备时:xcrun simctl uninstall <device> <bundle identifier>

9. 截图:xcrun simctl io booted screenshot screenshot.png

会发现在当前目录下会多了一张照片

多设备时: xcrun simctl io <device> screenshot screenshot.png

10. 录屏:xcrun simctl io booted recordVideo example.mp4

多设备时:xcrun simctl io <device> recordVideo example.mp4

11. 日志: tail -f <filename>

日志文件的路径:
/Users/$UserName/Library/Logs/CoreSimulator/$simulator_hash/system.log

12. 更多

 
 

转载于:https://www.cnblogs.com/xiyuan2016/p/9929782.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值