Skip to content

Commit

Permalink
Create xcode.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin T. Coughlin <[email protected]>
  • Loading branch information
KevinTCoughlin authored Oct 26, 2024
1 parent 10df3e0 commit 862036b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/xcode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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-latest

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]}

0 comments on commit 862036b

Please sign in to comment.