Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,23 @@ fi
# Set scheme
if [[ -z "${SCHEME:-}" ]]; then
if [[ "$SPM" == true ]];then
SCHEME="${SAMPLE}Example (${OS})"
# Get the list of schemes
schemes=$(xcodebuild -list -project "${DIR}/${SAMPLE}Example.xcodeproj" |
grep -E '^\s+' |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current grep command is not specific enough and can incorrectly match targets or build configurations as schemes, because it only checks for indentation. This can lead to build failures if a target name happens to match a scheme name pattern. To make this more robust, you should first isolate the 'Schemes:' section of the xcodebuild -list output before extracting the scheme names.

Suggested change
grep -E '^\s+' |
sed -n '/Schemes:/,/^$/p' | sed '1d;$d' |

sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')

# Check for the base scheme name
if echo "$schemes" | grep -q "^${SAMPLE}Example$"; then
SCHEME="${SAMPLE}Example"
# Check for the OS-suffixed scheme name
elif echo "$schemes" | grep -q "^${SAMPLE}Example (${OS})$"; then
SCHEME="${SAMPLE}Example (${OS})"
else
echo "Error: Could not find a suitable scheme for ${SAMPLE}Example in ${OS}."
echo "Available schemes:"
echo "$schemes"
exit 1
fi
else
SCHEME="${SAMPLE}Example${SWIFT_SUFFIX:-}"
fi
Expand Down