Skip to content

Update ios.yml

Update ios.yml #14

Workflow file for this run

name: iOS Build and Test Workflow
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build and Test iOS App
runs-on: macos-latest
steps:
# Step 1: Checkout Code
- name: Checkout
uses: actions/checkout@v4
# Step 2: Set Working Directory (using the directory directly in subsequent steps)
# This step is implicit by including the subdirectory in commands below.
# Step 3: Detect Default Scheme
- name: Detect Default Scheme
id: scheme-detection
run: |
cd Neurology-iOS-Client-App/
scheme_list=$(xcodebuild -list -json)
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['schemes'][0]")
echo "scheme=$default" >> $GITHUB_ENV
echo "Detected scheme: $default"
# Step 4: Build the App
- name: Build
env:
platform: iOS Simulator
run: |
cd Neurology-iOS-Client-App/.xcodeproj
# Detect file type (project or workspace)
if [ -e *.xcworkspace ]; then
filetype_parameter="workspace"
file_to_build=$(ls *.xcworkspace | head -1)
else
filetype_parameter="project"
file_to_build=$(ls *.xcodeproj | head -1)
fi
file_to_build=$(echo $file_to_build | xargs) # Clean whitespace
# Detect simulator device
device=$(xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | sed 's/ Simulator$//')
pwd
xcodebuild build-for-testing \
-"$filetype_parameter" "$file_to_build" \
-scheme "$scheme" \
-destination "platform=$platform,name=$device"
# Step 5: Run Tests
- name: Test
env:
platform: iOS Simulator
run: |
cd Neurology-iOS-Client-App/
# Detect file type (project or workspace)
if [ -e *.xcworkspace ]; then
filetype_parameter="workspace"
file_to_build=$(ls *.xcworkspace | head -1)
else
filetype_parameter="project"
file_to_build=$(ls *.xcodeproj | head -1)
fi
file_to_build=$(echo $file_to_build | xargs) # Clean whitespace
# Detect simulator device
device=$(xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | sed 's/ Simulator$//')
xcodebuild test-without-building \
-"$filetype_parameter" "$file_to_build" \
-scheme "$scheme" \
-destination "platform=$platform,name=$device"