Skip to content

Instantly share code, notes, and snippets.

@kylehughes
Created July 1, 2025 15:53
Show Gist options
  • Save kylehughes/8a839477244206f0492c08503be66402 to your computer and use it in GitHub Desktop.
Save kylehughes/8a839477244206f0492c08503be66402 to your computer and use it in GitHub Desktop.
Bash script for testing a single Swift package inside of an Xcode project.
#!/bin/bash
# --- Configuration ---
# Source shared configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/xcodebuild-config.sh"
# --- Script ---
# Check if package name was provided
if [ -z "$1" ]; then
echo "Error: Package name required"
echo "Usage: $0 <package-name>"
echo "Example: $0 Engine"
exit 1
fi
PACKAGE_NAME="$1"
PACKAGE_PATH="Packages/$PACKAGE_NAME"
# Check if package exists
if [ ! -d "$PACKAGE_PATH" ]; then
echo "Error: Package '$PACKAGE_NAME' not found at $PACKAGE_PATH"
echo "Available packages:"
ls -1 Packages/
exit 1
fi
echo "Testing package: $PACKAGE_NAME"
# Run tests for the package using xcodebuild
xcodebuild test \
-project "$PROJECT" \
-scheme "$SCHEME" \
-destination "$TEST_DESTINATION" \
-only-testing:"${PACKAGE_NAME}Tests"
echo "Finished testing package: $PACKAGE_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment