I have UI test (for an iOS app) that opens iOS photo gallery and taps on specific image.
I want to have custom script that will copy this image to simulator’s photo gallery at the beginning of the test of even right before it will start.
I have sh script that works when I manually run it after simulator is launched, but I want it to be executed during test run on Xcode Cloud.
This is script code
#!/bin/bash
# Get the UDID of the simulator (adjust for your target simulator)
SIMULATOR_UDID=$(xcrun simctl list devices | grep "Booted" | awk -F '[()]' '{print $2}')
# Path to the image
IMAGE_PATH="./myImage.jpg"
# Add the image to the simulator gallery
xcrun simctl addmedia $SIMULATOR_UDID $IMAGE_PATH
I already tried to add it to pre-test actions for Test Scheme and to Build Phases of UI test target – no luck, I even wasn’t able to find logs related to this script execution.
2
Answers
Here is detailed answer on the matter of scripts for Xcode Cloud. And this is related apple documentation page. Please, let me know if it helped.
Try this script code: