How can I tell when the iOS simulator has booted to its home screen?

放肆的年华 提交于 2019-12-10 17:15:53

问题


I use open -n /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/ --args -CurrentDeviceUDID xxxxx to start a simulator alongside any number of others, and I can poll xcrun simctl list | grep xxxxx to find out when it's started its boot process.

How can I determine that the simulator has finished its boot-up process and is idling at its home screen?

Currently I'm polling ~/Library/Logs/iOS Simulator/{version}/system.log until it's quiet for a few seconds, but that's kinda lame.

Is there something nicer, like an xcrun simctl getenv?


回答1:


You could poll the com.apple.springboard.services mach service for checkin. Eg:

~ $ simctl spawn booted launchctl print system | grep com.apple.springboard.services
         0x1c407    M   D   com.apple.springboard.services
...
~ $ simctl spawn booted launchctl print system | grep com.apple.springboard.services
         0x1c407    M   A   com.apple.springboard.services

edit: With recent builds, you can also run xcrun simctl bootstatus <UDID> to monitor this progress. That's likely a much more elegant solution than polling launchctl these days.

edit (again): In addition to using 'xcrun simctl bootstatus ' to monitor the progress, you can use it to kick off the boot if it hasn't started already. Check xcrun simctl help bootstatus for more info.



来源:https://stackoverflow.com/questions/37033405/how-can-i-tell-when-the-ios-simulator-has-booted-to-its-home-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!