@@ -33,28 +33,29 @@ echo "Finding matching device simulator..."
3333XCODE_OUTPUT=$( xcodebuild -showdestinations -workspace " $WORKSPACEPATH " -scheme " $SCHEME " )
3434XCODE_OUTPUT_REGEX=" m/\{\splatform:(.*\sSimulator),.*id:([A-F0-9\-]{36}),.*OS:(\d{1,2}\.\d),.*name:([a-zA-Z0-9\(\)\s]*)\s\}/g"
3535
36- # Provide diagnostic output of device list matching the specified platform and device.
37- SIMPATFORM_LIST_PREVIEW=$( echo " ${XCODE_OUTPUT} " | perl -nle ' if (' $XCODE_OUTPUT_REGEX ' ) { ($plat, $id, $os, $name) = ($1, $2, $3, $4); if ($plat =~ /' $SIMPLATFORM_REGEX ' / and $name =~ /' $SIMDEVICE_REGEX ' /) { print "- ${name} (${plat} - ${os}) - ${id}"; } }' )
38- if [[ -z $SIMPATFORM_LIST_PREVIEW ]]; then echo " Error: no matching simulators available." ; exit 1; fi
39- echo " Available simulators matching the target:"
40- echo " $SIMPATFORM_LIST_PREVIEW "
41-
4236# Parse device list into a format that is easier to parse out.
4337SIMPLATFORMS=$( echo " ${XCODE_OUTPUT} " | perl -nle ' if (' $XCODE_OUTPUT_REGEX ' ) { ($plat, $id, $os, $name) = ($1, $2, $3, $4); if ($plat =~ /' $SIMPLATFORM_REGEX ' / and $name =~ /' $SIMDEVICE_REGEX ' /) { print "${name}\t${plat}\t${os}\t${id}"; } }' | sort -rV)
4438SIMPLATFORMS_REGEX=" m/(.*)\t(.*)\t(.*)\t(.*)/g"
4539
46- # Find simulator ID
40+ # Find simulator ID.
4741if [[ -n $OSVERSION_REGEX ]]; then
4842 echo " Finding OS version using regex: ${OSVERSION_REGEX} ."
49- DESTID=$( echo " ${SIMPLATFORMS} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); if ($os =~ /' $OSVERSION_REGEX ' /) { print "${id}"; } }' | head -n 1)
50- DESTDESC=$( echo " ${SIMPLATFORMS} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); if ($os =~ /' $OSVERSION_REGEX ' /) { print "${name} (${plat} - ${os}) - ${id}"; } }' | head -n 1)
43+ MATCHES=$( echo " ${SIMPLATFORMS} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); if ($os =~ /' $OSVERSION_REGEX ' /) { print "${name}\t${plat}\t${os}\t${id}"; } }' )
44+ TOPLINEMATCH=$( echo " ${MATCHES} " | head -n 1)
45+ DESTID=$( echo " ${TOPLINEMATCH} " | perl -le ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); if ($os =~ /' $OSVERSION_REGEX ' /) { print "${id}"; } }' )
46+ DESTDESC=$( echo " ${TOPLINEMATCH} " | perl -le ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); if ($os =~ /' $OSVERSION_REGEX ' /) { print "${name} (${plat} - ${os}) - ${id}"; } }' | head -n 1)
5147else
5248 echo " Finding latest OS version for target."
53- LINE=$( echo " ${SIMPLATFORMS} " | head -1)
54- DESTID=$( echo " ${LINE} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); print $id; }' )
55- DESTDESC=$( echo " ${LINE} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); print "${name} (${plat} - ${os}) - ${id}"; }' )
49+ MATCHES=" $SIMPLATFORMS "
50+ TOPLINEMATCH=$( echo " ${SIMPLATFORMS} " | head -1)
51+ DESTID=$( echo " ${TOPLINEMATCH} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); print $id; }' )
52+ DESTDESC=$( echo " ${TOPLINEMATCH} " | perl -nle ' if (' $SIMPLATFORMS_REGEX ' ) { ($name, $plat, $os, $id) = ($1, $2, $3, $4); print "${name} (${plat} - ${os}) - ${id}"; }' )
5653fi
5754
55+ # Provide diagnostic output of all matching simulators.
56+ echo " Available simulators matching the target:"
57+ echo " $( echo " $MATCHES " | while read line; do echo " - $line " ; done)"
58+
5859# Exit out if no simulators matched the criteria.
5960if [[ -z $DESTID ]]; then echo " ⛔️ Error: No matching simulators available." ; exit 1; fi
6061
0 commit comments