iOS模擬器命令xcrun simctl系列(自動化測試)


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. 更多

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM