Kamchatka
Kamchatka

Reputation: 3675

Show simulator when running xcodebuild test in command line

Since Xcode 9, xcodebuild runs the simulators in headless mode (= the simulator is not launched in the foreground) which is a great improvement.

However, I need to debug an issue with xcodebuild and UI tests and would like to see what happens in the simulator. Is it possible to force the simulator to be displayed when running tests with xcodebuild?

Note: running in Xcode is not an answer :) because I cannot reproduce the issue in Xcode.

Thanks!

Upvotes: 5

Views: 2057

Answers (2)

Kevin ABRIOUX
Kevin ABRIOUX

Reputation: 17695

It's actually possible but a little bit tricky

First of all you have to select your target and your target simulator

enter image description here

After that, you have to build your app for testing :

enter image description here

Go in your project's derived data and open Build/Product folder in terminal, for example :

/Users/CURRENT_USER_FOLDER/Library/Developer/Xcode/DerivedData/PROJECT_DERIVED_DATA/Build/Products

Retrieve your simulator id with instruments -s devices command :

enter image description here

Execute this command to run you test on your simulator

xcodebuild test-without-building \
    -xctestrun <yourfile.xctestrun> \
    -destination id=<iphoneID>

Test will launch on your simulator without using XCode and you will be able to see UI animations on your simulator

Upvotes: 0

durgasunil
durgasunil

Reputation: 98

You can do this by launching Xcode (right click) and open Developer Tool -> Simulator, while the tests are running in headless mode via xcodebuild.

This will show all the simulator screens which are running in headless mode.

Upvotes: 2

Related Questions