Mac Simulator (Xcode) wait for startup command

Viewed 1224

In Android I can run this to start emulator

emulator @NAME

and this to wait for it to load completely and be ready to use

adb wait-for-device

Is there an equivalent for iOS Simulator on Mac? I use default Xcode Simulator. So start of simulator

xcrun simctl boot deviceID

and wait for it to load completely (just an example of what I'm thinking of)

xcrun simctl wait deviceId
2 Answers

There is a not-exactly-documented simctl command of xcrun simctl bootstatus deviceID

It doesn't appear in the normal output of xcrun simctl help, but it does have xcrun simctl help bootstatus

From my own playing with it, if you call it, when the bootstatus command exits, your simulator should be fully operational. But since it isn't exactly documented your mileage may vary.

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

I did find an answer which works great for me. I am using "xcrun simctl spawn <UDID> launchctl print system | grep com.apple.springboard.services" and looking for these values in the output:

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