Skip to content

Fix tests build

Fix tests build #12

Workflow file for this run

name: Xcode - Build and Analyze
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build and analyze default scheme using xcodebuild
runs-on: macos-15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine Default Scheme
run: |
# Get the default scheme from the target list
scheme=$(xcodebuild -list -json | jq -r '.project.targets[0]')
echo "Default scheme detected: $scheme"
echo "scheme=$scheme" >> $GITHUB_ENV
- name: Identify Xcode Project or Workspace
run: |
# Check if workspace or project exists, and set the build target
if [[ -n "$(ls *.xcworkspace 2>/dev/null)" ]]; then
filetype="workspace"
file_to_build=$(ls *.xcworkspace | head -n 1)
elif [[ -n "$(ls *.xcodeproj 2>/dev/null)" ]]; then
filetype="project"
file_to_build=$(ls *.xcodeproj | head -n 1)
else
echo "No .xcworkspace or .xcodeproj found." >&2
exit 1
fi
echo "Detected Xcode $filetype: $file_to_build"
echo "filetype=$filetype" >> $GITHUB_ENV
echo "file_to_build=$file_to_build" >> $GITHUB_ENV
- name: Build and Analyze
env:
scheme: ${{ env.scheme }}
filetype: ${{ env.filetype }}
file_to_build: ${{ env.file_to_build }}
run: |
# Clean, build, and analyze the project
xcodebuild clean build analyze -scheme "$scheme" -"$filetype" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]}