Skip to content

Commit 5652d55

Browse files
authored
Update ios.yml with first available simulator (#308)
1 parent 9834683 commit 5652d55

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/ios.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,29 @@ jobs:
1717
- name: Build and Test
1818
env:
1919
scheme: ${{ 'SDKHostApp' }}
20-
platform: ${{ 'iOS Simulator' }}
21-
os: ${{ '16.2' }}
22-
device: ${{ 'iPhone 13' }}
2320
run: |
2421
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
22+
2523
if [ $scheme = default ]; then scheme=$(cat default); fi
24+
25+
# Determine file to build: .xcworkspace or .xcodeproj
2626
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
27+
28+
# Clean up whitespace
2729
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
28-
xcodebuild test -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,OS=$os,name=$device"
30+
31+
# Find first available simulator
32+
device_name=$(xcrun simctl list devices available | grep "iPhone" | head -n 1 | sed -E 's/^[[:space:]]*([^()]+)[[:space:]]*\(.*$/\1/' | awk '{$1=$1; print}')
33+
34+
if [ -z "$device_name" ]; then
35+
echo "❌ Failed to find a valid iOS device."
36+
exit 1
37+
fi
38+
39+
echo "📱 Using device: $device_name"
40+
41+
# Build and run the tests
42+
xcodebuild test \
43+
-scheme "$scheme" \
44+
-"$filetype_parameter" "$file_to_build" \
45+
-destination "platform=iOS Simulator,name=$device_name"

0 commit comments

Comments
 (0)