How to solve 'Test runner exited before starting test execution' error for iPhone Devices

Context -

We have E2E Testing running on the CI on the iPhone devices.

The script performs the following steps -

  1. Build the Test runner app from code.
  2. Extracts the app file from the IPA.
  3. Re-codesign the app with the required Provision Profiles.
  4. Creates a .xctestrun file
  5. Uses the xcodebuild command like the following to run the test -
xcodebuild -sdk iphoneos -destination id=<device_id> -xctestrun <path_to_xctestrun_file> -resultBundlePath <path_to_test_bundle_file> test-without-building -only-testing:E2ETestsBundle.xctest/<test_filter>
  1. The above command installs the runner and target app into the device and starts executing the test.

The apps get installed and uninstalled at each run during a single execution.

Problem -

During the execution, the xcodebuild CLI tool, suddenly loses connection to the device and is not able to install the apps into the device and then results in the following error -

Testing failed:
        E2ETestsBundle-Runner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test runner exited before starting test execution. If you believe this error represents a bug, please attach the log file at /var/folders/1r/0xlnbmzd0yj3m_cc7p95yb4r0000gn/T/tmpl7d9p1s6/testResults.bundle/Staging/1_Test/Diagnostics/E2ETestsBundle-Configuration-Test Scheme Action-Iteration-1/E2ETestsBundle/Session-E2ETestsBundle-2022-04-13_205520-muaMCx.log))


Points to note -

  1. The xcodebuild CLI tool will keep on failing with the error once it occurred until recovered.
  2. Even while the xcodebuild is in a failed state, the devices are still accessible via Xcode IDE and other CLI tools like libimobiledevice and are able to install both the test runner and target applications.
  3. This is occurring intermittently across all devices models and across subversions of iOS 14 and 15.

Recovery -

  1. The only way to recover is to reboot the device.
  2. Even after a reboot, the devices start facing this exception again after a few days of execution.

As we can’t keep on rebooting the device every time before execution, we need a solution to fix this problem. Any help would be appreciated!!

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum