Here some context to introduce the topic: I have an iOS application with some UITests. I run UITests in CI using xcodebuild. Execution of UITests involves two binaries running in the simulator: the test-runner and the application under test. During the execution of the tests sometimes things go wrong, and tests fail. After execution finishes, I am able to obtain the test-runner logs from the stdout of xcodebuild in order to try and troubleshoot the test failure.
But... I could not find a way of accessing the application logs. Application logs generated during a UITest run are very valuable, as they contain logs related to what went wrong inside the application under test at the moment of the failure: debug logs, crash logs...
Usually, the answers to below questions cannot be found in the test-runner logs, and only shows up in the application logs:
- Why a network request failed?
- Why the application crashed?
Without application logs, answering those questions is not trivial, and can take several hours of debugging.
After investigating, the only way I could find to obtain the application logs is running the UITests with Xcode, as Xcode somehow is able to gather both the test-runner logs and the application logs:
So here my questions:
- How is Xcode able to capture the application logs during UITests?
- Is there anyway to gather the application logs when running UITests with xcodebuild?