@@ -27,6 +27,12 @@ if [[ -z "${SPM:-}" ]]; then
2727 SPM=false
2828 echo " Defaulting to SPM=$SPM "
2929fi
30+ if [[ -z " ${OS:- } " ]]; then
31+ OS=iOS
32+ DEVICE=" iPhone ${iphone_version} "
33+ echo " Defaulting to OS=$OS "
34+ echo " Defaulting to DEVICE=$DEVICE "
35+ fi
3036
3137# Set have_secrets to true or false.
3238source scripts/check_secrets.sh
4551# Set scheme
4652if [[ -z " ${SCHEME:- } " ]]; then
4753 if [[ " $SPM " == true ]]; then
48- SCHEME=" ${SAMPLE} Example (${OS} )"
54+ # Get the list of schemes
55+ schemes=$( xcodebuild -list -project " ${DIR} /${SAMPLE} Example.xcodeproj" |
56+ grep -E ' ^\s+' |
57+ sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' )
58+
59+ # Check for the OS-suffixed scheme name
60+ if echo " $schemes " | grep -q " ^${SAMPLE} Example (${OS} )$" ; then
61+ SCHEME=" ${SAMPLE} Example (${OS} )"
62+ # Check for the Swift-suffixed scheme
63+ elif echo " $schemes " | grep -q " ^${SAMPLE} ExampleSwift$" ; then
64+ SCHEME=" ${SAMPLE} ExampleSwift"
65+ # Check for the base scheme name
66+ elif echo " $schemes " | grep -q " ^${SAMPLE} Example$" ; then
67+ SCHEME=" ${SAMPLE} Example"
68+ else
69+ echo " Error: Could not find a suitable scheme for ${SAMPLE} Example in ${OS} ."
70+ echo " Available schemes:"
71+ echo " $schemes "
72+ exit 1
73+ fi
4974 else
5075 SCHEME=" ${SAMPLE} Example${SWIFT_SUFFIX:- } "
5176 fi
0 commit comments