fix: remove trailing commas in Swift for Xcode <16.3 compatibility#186
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a compilation compatibility issue for users running Xcode versions prior to 16.3 (Swift < 6.1) by removing trailing commas from function/initializer argument lists in the iOS XCUITest runner Swift files. These trailing commas rely on SE-0439, which was only introduced in Swift 6.1. Additionally, a packageManager field is added to package.json.
Changes:
- Removed 12 trailing commas across 5 Swift files in the iOS XCUITest runner to restore compatibility with Xcode < 16.3 / Swift < 6.1
- Added
packageManagerfield topackage.jsonpinningpnpm@10.19.0
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
package.json |
Added packageManager field for pnpm version pinning (unrelated to trailing comma fix) |
RunnerTests.swift |
Removed 2 trailing commas from array literal initializers |
RunnerTests+Transport.swift |
Removed 2 trailing commas from function call arguments and array literal |
RunnerTests+Snapshot.swift |
Removed 5 trailing commas from struct initializer argument lists |
RunnerTests+ScreenRecorder.swift |
Removed 2 trailing commas from dictionary literal initializers |
RunnerTests+CommandExecution.swift |
Removed 1 trailing comma from function call arguments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
package.json
Outdated
| "typescript": "^5.9.3" | ||
| } | ||
| }, | ||
| "packageManager": "pnpm@10.19.0+sha512.c9fc7236e92adf5c8af42fd5bf1612df99c2ceb62f27047032f4720b33f8eacdde311865e91c411f2774f618d82f320808ecb51718bfa82c060c4ba7c76a32b8" |
There was a problem hiding this comment.
The packageManager field addition is not mentioned in the PR description, which only describes removing trailing commas from Swift files. This change pins pnpm@10.19.0 and enables Corepack enforcement, which is unrelated to the Swift compatibility fix and could affect other contributors' workflows. Consider either documenting this in the PR description or splitting it into a separate PR.
Remove trailing commas from function/initializer argument lists in the iOS XCUITest runner Swift source files. SE-0439 trailing commas in comma-separated lists require Swift 6.1+ (Xcode 16.3+), but the runner is compiled locally by users who may have older Xcode versions. Users with Xcode 16.2 (Swift 6.0.3) encounter build failures: error: unexpected ',' separator This causes the runner to never start, surfacing as: Error (COMMAND_FAILED): Runner did not accept connection (simctl spawn) Files fixed (12 trailing commas removed): - RunnerTests+Snapshot.swift (5) - RunnerTests+Transport.swift (2) - RunnerTests+CommandExecution.swift (1) - RunnerTests+ScreenRecorder.swift (2) - RunnerTests.swift (2) Verified: pnpm build:xcuitest passes (TEST BUILD SUCCEEDED).
0d53f4f to
ca2ce34
Compare
|
We’re running our tests on 26,2 but rely on cache, interesting |
Problem
Users with Xcode 16.2 / Swift 6.0.3 (or older) cannot use
agent-devicebecause the iOS XCUITest runner fails to compile. The error manifests as:The underlying build failure is:
in multiple Swift files within the
ios-runnerdirectory.Root Cause
SE-0439 (Allow trailing comma in comma-separated lists) was introduced in Swift 6.1(ships with
Xcode 16.3+, MayXcode 16.3, released March 31, 2025). The trailing commas in function/initializer argument lists were introduced in commit 9b443c5 (PR##149,refactor: split RunnerTests into focused files).Since
agent-devicedistributes Swift source files via npm and compiles them locally on the user'smachine, users with Xcode versions prior to 16.3 hit compilation errorsmachine viaxcodebuild, users with Xcode versions prior to 16.3 hit compilation errors. The CI (macos-26runner with Xcode 26) uses Swift 6.1+, so this was not caught.The CI (
macos-26runner) uses Xcode 26 with Swift 6.1+, so this was not caught.Fix
Removed 12 trailing commas from function/initializer argument lists across 5 Swift files:
All changes are purely comma removals — no functional changes.
Verification
pnpm build:xcuitest→** TEST BUILD SUCCEEDED **(tested on Xcode 16.2 / Swift 6.0.3)agent-device presscommandsnow workwork after fix (runner spawns and accepts connections))in any Swift fileSuggestion
Consider adding a CI job that builds the XCUITest runner with the minimum supported Xcode version (e.g., Xcode 16.2) to catch future Swift language compatibility regressions, since the runner is compiled on user machines with varying Xcode versions.
References
- SE-0439 Proposal: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0439-trailing-comma-lists.md
- Swift 6.1 Release Blog (official swift.org): https://swift.org/blog/swift-6.1-released/ — "Swift 6.1 extends trailing comma support to tuples, parameter and argument lists..."
- What's new in Swift 6.1 (Hacking with Swift): https://www.hackingwithswift.com/articles/276/whats-new-in-swift-6-1 — "allowed from Swift 6.1 onwards"
- Xcode 16.3 = Swift 6.1 (xcodereleases.com): https://xcodereleases.com/ — Xcode 16.3 Release (16E140), March 31 2025, Swift 6.1 (6.1.0.110.21)
- InfoQ coverage: https://www.infoq.com/news/2025/05/swift-6-1-released/ — "Swift 6.1, included in Xcode 16.3, introduces... support for trailing commas in lists"
- Swift Evolution Monthly (FlineDev): https://www.fline.dev/swift-evolution-monthly-may-november-2024/ — SE-0439 acceptance & review links
- Commit that introduced trailing commas: callstackincubator/agent-device@9b443c5(PR refactor: split RunnerTests into focused files #149)
ProblemUsers with Xcode 16.2 / Swift 6.0.3 (or older) cannot use agent-device because the iOS XCUITest runner fails to compile. The error manifests as:
Error (COMMAND_FAILED): Runner did not accept connection (simctl spawn)
The underlying build failure is:
error: unexpected ',' separator
in multiple Swift files within the ios-runner directory.
Root Cause
SE-0439 (Allow trailing comma in comma-separated lists) was introduced in Swift 6.1 (ships with Xcode 16.3+, MayXcode 16.3, released March 31, 2025). The trailing commas in function/initializer argument lists were introduced in commit 9b443c5 (PR # #149, refactor: split RunnerTests into focused files).
Since agent-device distributes Swift source files via npm and compiles them locally on the user's machine, users with Xcode versions prior to 16.3 hit compilation errorsmachine via xcodebuild, users with Xcode versions prior to 16.3 hit compilation errors. The CI (macos-26 runner with Xcode 26) uses Swift 6.1+, so this was not caught.
The CI (macos-26 runner) uses Xcode 26 with Swift 6.1+, so this was not caught.
Fix
Removed 12 trailing commas from function/initializer argument lists across 5 Swift files:
File Commas Removed
RunnerTests+Snapshot.swift 5
RunnerTests+Transport.swift 2
RunnerTests+CommandExecution.swift 1
RunnerTests+ScreenRecorder.swift 2
RunnerTests.swift 2
All changes are purely comma removals — no functional changes.
Verification
pnpm build:xcuitest → ** TEST BUILD SUCCEEDED ** (tested on Xcode 16.2 / Swift 6.0.3)
agent-device press commands now workwork after fix (runner spawns and accepts connections)
Python scan confirms zero trailing commas remain before closing ) in any Swift file
Suggestion
Consider adding a CI job that builds the XCUITest runner with the minimum supported Xcode version (e.g., Xcode 16.2) to catch future Swift language compatibility regressions, since the runner is compiled on user machines with varying Xcode versions.
References
SE-0439 Proposal: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0439-trailing-comma-lists.md
Swift 6.1 Release Blog (official swift.org): https://swift.org/blog/swift-6.1-released/ — "Swift 6.1 extends trailing comma support to tuples, parameter and argument lists..."
What's new in Swift 6.1 (Hacking with Swift): https://www.hackingwithswift.com/articles/276/whats-new-in-swift-6-1 — "allowed from Swift 6.1 onwards"
Xcode 16.3 = Swift 6.1 (xcodereleases.com): https://xcodereleases.com/ — Xcode 16.3 Release (16E140), March 31 2025, Swift 6.1 (6.1.0.110.21)
InfoQ coverage: https://www.infoq.com/news/2025/05/swift-6-1-released/ — "Swift 6.1, included in Xcode 16.3, introduces... support for trailing commas in lists"
Swift Evolution Monthly (FlineDev): https://www.fline.dev/swift-evolution-monthly-may-november-2024/ — SE-0439 acceptance & review links
Commit that introduced trailing commas: 9b443c5 (PR #149)