How to retrieve app logs when running UITests?

106 views Asked by At

As stated, any way of retrieving App Logs, not just the test logs, using Xcode 14? all I see in xcresult files are the Runner's logs, but I need the app logs as well both when running via Xcode or through cli

1

There are 1 answers

2
henrique On

On Xcode 15 Reveal Diagnostics in Finder context menu is gone, which seems VERY ODD. I'm currently facing the same problem as described in this Apple dev forum thread and I opened a Feeback Report FB13615178.

In the meantime, you can use xcresulttool.

Get the object graph to get the IDs for the objects you want to export.

xcrun xcresulttool graph --path YourResult.xcresult/ > graph.log

Search for StandardOutputAndStandardError to see where it is in the graph. Get its ID and export it:

xcrun xcresulttool export \
--type directory \
--path YourResult.xcresult/ \
--output-path ./Output \
--id <ID-HERE>

I believe we can put together a script to automatically extract the logs on a CI environment - this is our current goal. Please share if you have any progress.


On Xcode 14: Open the .xcresult in Xcode, right-click a test, and select Reveal Diagnostics in Finder. You should see your simulator(s) folder(s) and inside of one of those you'll see StandardOutputAndStandardError-bundle-id.txt file.