Skip to content

Commit 658b0b6

Browse files
committed
Updated iOS.yml that uses latest OS / device version
1 parent 642988f commit 658b0b6

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

.github/workflows/ios.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,33 @@ jobs:
1717
- name: Build and Test
1818
env:
1919
scheme: ${{ 'SDKHostApp' }}
20-
platform: ${{ 'iOS Simulator' }}
21-
os: ${{ latest }}
22-
device: ${{ 'iPhone 16' }}
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 latest available iOS runtime identifier
32+
latest_runtime_id=$(xcrun simctl list runtimes | grep -E "iOS [0-9]+\.[0-9]*" | grep -v unavailable | sort -Vr | head -n 1 | sed -E 's/.*- (.*)$/\1/')
33+
34+
# Find a compatible simulator device name for that runtime
35+
device_name=$(xcrun simctl list devices available | grep "$latest_runtime_id" | head -n 1 | sed -E 's/^ (.+) \(.+\) \(.+\)$/\1/')
36+
37+
if [ -z "$latest_runtime_id" ] || [ -z "$device_name" ]; then
38+
echo "❌ Failed to find a valid iOS runtime or device."
39+
exit 1
40+
fi
41+
42+
echo "🛠 Using runtime: $latest_runtime_id"
43+
echo "📱 Using device: $device_name"
44+
45+
# Build and run the tests
46+
xcodebuild test \
47+
-scheme "$scheme" \
48+
-"$filetype_parameter" "$file_to_build" \
49+
-destination "platform=iOS Simulator,OS=$latest_runtime_id,name=$device_name"

0 commit comments

Comments
 (0)