test-unit.sh (761B)
1 #!/bin/bash 2 set -euo pipefail 3 4 MAJOR="${1:-26}" 5 RUNTIME=$(xcrun simctl list runtimes available \ 6 | grep "iOS ${MAJOR}\." \ 7 | sed 's/.*iOS \([0-9.]*\).*/\1/' \ 8 | sort -t. -k1,1n -k2,2n \ 9 | tail -1) 10 11 if [ -z "$RUNTIME" ]; then 12 echo "No available iOS ${MAJOR}.x simulator runtime found." >&2 13 exit 1 14 fi 15 16 DEVICE=$(xcrun simctl list devices available "iOS ${RUNTIME}" \ 17 | grep "iPhone" \ 18 | head -1 \ 19 | sed 's/^ *\(.*\) ([A-F0-9-]*).*/\1/') 20 21 if [ -z "$DEVICE" ]; then 22 echo "No available iPhone simulator found for iOS ${RUNTIME}." >&2 23 exit 1 24 fi 25 26 echo "Using ${DEVICE}, iOS ${RUNTIME}" 27 xcodebuild test \ 28 -scheme "Crossmate" \ 29 -destination "platform=iOS Simulator,name=${DEVICE},OS=${RUNTIME}" \ 30 -only-testing:"Crossmate Unit Tests" \ 31 2>&1