We currently try to run tests on 4 physically attached iPhones all on ios 17. When tests are concurrently running we occasionally get failures that look like this:
Testing failed:
Failed to install the app on the device.
SwiftUITests-Runner encountered an error (Failed to install or launch the test runner. (Underlying Error: Failed to install the app on the device. (Underlying Error: Connection with the remote side was unexpectedly closed : { count = 1, transaction: 0, voucher = 0x0, contents =
"XPCErrorDescription" => { length = 22, contents = "Connection interrupted" }
}. Unhandled error domain IXRemoteErrorDomain, code 6))
I noticed that when relying on xcodebuild to install the target app and test runner it cannot install concurrently/parallel on all 4 devices but instead does each device sequentially causing the test to hang. The same behavior can be exhibited when trying to install an app concurrently on 4 different phones with xcrun devicectl as well.
STEPS TO REPRODUCE
Trigger a test with xcodebuild on 4 different phones at the same time where xcodebuild also needs to install the target apps.
Currently using Xcode15.2 and iOS 17.5.1