Skip to content

Commit 20c0fbc

Browse files
committed
Modernize iOS CI workflow
- Bump actions/checkout v2 → v4 (silences Node 20 deprecation warning). - Pin runner to macos-15 and select Xcode via maxim-lobanov/setup-xcode (latest-stable), so the build runs against the latest available Xcode rather than whatever macos-latest happens to alias to. - Add concurrency cancel-in-progress to drop superseded PR runs. - Replace the inline shell hacks with a small JSON-based simulator picker that returns a UDID (sturdier than name parsing). - Pipe xcodebuild through xcbeautify for readable test output, and pass CODE_SIGNING_ALLOWED=NO so CI never tries to sign.
1 parent caaf069 commit 20c0fbc

1 file changed

Lines changed: 46 additions & 30 deletions

File tree

.github/workflows/ios.yml

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,56 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
build:
11-
name: Build and Test SDKHostApp scheme using any available iPhone simulator
12-
runs-on: macos-latest
15+
name: Build & test SDKHostApp
16+
runs-on: macos-15
17+
env:
18+
SCHEME: SDKHostApp
19+
PROJECT: IFTTT SDK.xcodeproj
1320

1421
steps:
1522
- name: Checkout
16-
uses: actions/checkout@v2
17-
- name: Build and Test
18-
env:
19-
scheme: ${{ 'SDKHostApp' }}
23+
uses: actions/checkout@v4
24+
25+
- name: Select Xcode
26+
uses: maxim-lobanov/setup-xcode@v1
27+
with:
28+
xcode-version: latest-stable
29+
30+
- name: Toolchain versions
31+
run: |
32+
xcodebuild -version
33+
swift --version
34+
35+
- name: Pick iPhone simulator
36+
id: sim
37+
run: |
38+
udid=$(xcrun simctl list devices available --json | python3 -c '
39+
import json, sys
40+
data = json.load(sys.stdin)
41+
for runtime, devices in data["devices"].items():
42+
if "iOS" not in runtime:
43+
continue
44+
for dev in devices:
45+
if dev["name"].startswith("iPhone") and dev.get("isAvailable", False):
46+
print(dev["udid"])
47+
sys.exit(0)
48+
sys.exit("No available iPhone simulator found")
49+
')
50+
echo "destination=platform=iOS Simulator,id=$udid" >> "$GITHUB_OUTPUT"
51+
echo "Using simulator $udid"
52+
53+
- name: Build & test
2054
run: |
21-
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
22-
23-
if [ $scheme = default ]; then scheme=$(cat default); fi
24-
25-
# Determine file to build: .xcworkspace or .xcodeproj
26-
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
29-
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
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
55+
set -o pipefail
4256
xcodebuild test \
43-
-scheme "$scheme" \
44-
-"$filetype_parameter" "$file_to_build" \
45-
-destination "platform=iOS Simulator,name=$device_name"
57+
-project "$PROJECT" \
58+
-scheme "$SCHEME" \
59+
-destination "${{ steps.sim.outputs.destination }}" \
60+
CODE_SIGNING_ALLOWED=NO \
61+
| xcbeautify --renderer github-actions

0 commit comments

Comments
 (0)