Skip to content

Commit 4c5d62c

Browse files
committed
fix: modernize scripts/build-for-testing.sh
1 parent af28e6c commit 4c5d62c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

scripts/build-for-testing.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ if [[ -z "${SPM:-}" ]]; then
2727
SPM=false
2828
echo "Defaulting to SPM=$SPM"
2929
fi
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.
3238
source scripts/check_secrets.sh
@@ -45,7 +51,26 @@ fi
4551
# Set scheme
4652
if [[ -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

Comments
 (0)