Skip to content

Commit 0b31b4a

Browse files
committed
scheme logic
1 parent 1f6a43a commit 0b31b4a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/test.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,23 @@ fi
6969
# Set scheme
7070
if [[ -z "${SCHEME:-}" ]]; then
7171
if [[ "$SPM" == true ]];then
72-
SCHEME="${SAMPLE}Example (${OS})"
72+
# Get the list of schemes
73+
schemes=$(xcodebuild -list -project "${DIR}/${SAMPLE}Example.xcodeproj" |
74+
grep -E '^\s+' |
75+
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
76+
77+
# Check for the base scheme name
78+
if echo "$schemes" | grep -q "^${SAMPLE}Example$"; then
79+
SCHEME="${SAMPLE}Example"
80+
# Check for the OS-suffixed scheme name
81+
elif echo "$schemes" | grep -q "^${SAMPLE}Example (${OS})$"; then
82+
SCHEME="${SAMPLE}Example (${OS})"
83+
else
84+
echo "Error: Could not find a suitable scheme for ${SAMPLE}Example in ${OS}."
85+
echo "Available schemes:"
86+
echo "$schemes"
87+
exit 1
88+
fi
7389
else
7490
SCHEME="${SAMPLE}Example${SWIFT_SUFFIX:-}"
7591
fi

0 commit comments

Comments
 (0)