Mac模拟器(Xcode)等待启动命令

Mac Simulator (Xcode) wait for startup command

在Android中我可以运行这个来启动模拟器

emulator @NAME

等待它完全加载并准备好使用

adb wait-for-device

在 Mac 上是否有 iOS 模拟器的等效项?我使用默认的 Xcode 模拟器。所以模拟器开始

xcrun simctl boot deviceID

并等待它完全加载(只是我正在考虑的示例

xcrun simctl wait deviceId

我确实找到了一个非常适合我的答案。我正在使用 "xcrun simctl spawn <UDID> launchctl print system | grep com.apple.springboard.services" 并在输出中查找这些值:

"M   A   com.apple.springboard.services"
"U   A   com.apple.backboardd"
"M   D   com.apple.medialibraryd"
"M   A   com.apple.mobile.installd"

有一个not-exactly-documented simctl命令xcrun simctl bootstatus deviceID

它没有出现在xcrun simctl help的正常输出中,但确实有xcrun simctl help bootstatus

根据我自己的使用情况,如果调用它,当 bootstatus 命令退出时,您的模拟器应该可以完全运行。但由于没有准确记录,您的里程可能会有所不同。

xcrun simctl help bootstatus
Checks device boot status.
Usage: simctl bootstatus <device> [-bc]
    -b       Boot the device if it isn't already booted.
    -c       Continuously monitor boot status through multiple boot/shutdown cycles.

Monitors the specified device and prints boot status information until the device finishes booting. You can safely call this before you attempt to start booting the device.
/usr/bin/xcrun simctl bootstatus 88668721-0DF0-4167-8F3E-37190E8099C1
Monitoring boot status for AutomationDevice - iPad Air 2 - iOS 11.4 (88668721-0DF0-4167-8F3E-37190E8099C1).
[2019-05-23 03:50:56 +0000] Status=2, isTerminal=NO, Elapsed=00:00.
    Waiting on Data Migration
        Reason:(null)
        Migration Elapsed:00:00 seconds

[2019-05-23 03:50:56 +0000] Status=2, isTerminal=NO, Elapsed=00:01.
    Waiting on Data Migration
        Reason:Running plugin com.apple.MobileContainerManager.ContainerMigrator (ContainerMigrator.migrator, user-agnostic)
        Migration Elapsed:00:00 seconds

[spaaaaaaam...]

[2019-05-23 03:51:06 +0000] Status=2, isTerminal=NO, Elapsed=00:11.
    Waiting on Data Migration
        Reason:Running plugin com.apple.iTunesStore.migrator (iTunesStore.migrator)
        Migration Elapsed:00:10 seconds

[2019-05-23 03:51:08 +0000] Status=1, isTerminal=NO, Elapsed=00:12.
    Waiting on BackBoard

[2019-05-23 03:51:12 +0000] Status=4, isTerminal=NO, Elapsed=00:16.
    Waiting on System App

[2019-05-23 03:51:12 +0000] Status=4294967295, isTerminal=YES, Elapsed=00:17.
    Finished