Couple months ago, I’ve tried to set a mobile testing environment with Appium and one of the best tools to execute these tests was SauceLabs, a cloud platform dedicated for testing. SauceLabs is pretty easy to use but here is couple tricks to make even easier.

SauceLabs testing environment

To run your Appium tests on SauceLabs, you might need to upload your app as zip file to their Sauce Storage. This space is temporary: your app will be automatically removed from the cloud after 7 days. Everything is in command line, you can upload with one command and list your uploaded archives with another.

If you don’t have yet a continuous integration environment, by using a shell script in “Build Phases” in Xcode, you can actually upload to Sauce Storage automatically. It’s what’s happening if you’re using crash trackers like SplunkMint or NewRelic. Here is a temporary one to work with:


echo 'Zipping app'
zip -r "" "$tmpPath" > /dev/null

echo 'List files created'
ls -l

echo 'Display current md5 hash.'

echo 'Posting the zip archive to Saucelabs.'
curl -u "$username":"$accessKey" \
    -X POST \
    -H 'Content-Type: application/octet-stream' \
    --data-binary \

echo 'List zip files from Saucelabs.'
curl -u "$username":"$accessKey" \

I bind 3 params in my shell script, the temporary path of the app, a username and accessKey of SauceLabs. Then I archive the app and check its md5 hash: after uploading it SauceLabs return hash of your zip file too, that’s an easy way to check integrity.

The only thing missing is to add a build phase to my iOS project. In Xcode, selecting your target, under Build Phases, add a new run script phase and add this code in it.

SCRIPT=`/usr/bin/find "${SRCROOT}" -name | head -n 1`

if [ "${CONFIGURATION}" = "Debug" ]
echo "[info] Build for Debug ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"

Inspired by other script build phases as crash reporters, this code execute your shell script written above and giving in parameter your freshly built app and your saucelabs credentials. Finally, I run this script only when in debug at the first install, I’m not running UI testing for every build.

Finally, in our script files, some improvements could have been made like creating a temporary folder to work with when zipping the app and removing it at the end. Also, checking the number of parameters given might be a great idea. You can find an improved one in my repo here.