Skip to content

Migrate to Swift 6.2 - #51

Draft
DominikPalo wants to merge 7 commits into
mainfrom
codex/migrate-to-swift-6.2
Draft

DominikPalo wants to merge 7 commits into
mainfrom
codex/migrate-to-swift-6.2

Conversation

@DominikPalo

Copy link
Copy Markdown
Member

Summary

Switch OAuth2 to the Swift 6.2 toolchain and Swift 6 language mode, then address the resulting concurrency diagnostics with focused actor-boundary changes.

Closes #49.

Toolchain and project configuration

  • Raise swift-tools-version from 5.5 to 6.2.
  • Set the Xcode project SWIFT_VERSION to 6.0, which is the Xcode language-mode value for Swift 6.
  • Refresh Package.resolved to the current lockfile format and include the existing swift-log dependency.
  • Update the GitHub Actions matrix to run with Xcode 26 on macOS 15.
  • Update the README toolchain requirements to Swift 6.2 and Xcode 26.

Concurrency changes

AuthenticationServices UI boundary

ASWebAuthenticationPresentationContextProviding is main-actor isolated in the current SDK, while the OAuth implementation is protected by OAuth2Actor. The presentation-context providers are now @MainActor types. Authentication sessions and their providers are constructed and retained by small main-actor session holders, while completion processing explicitly returns to OAuth2Actor.

The iOS authenticationSessionEmbedded entry point is now async because constructing and starting the authentication session requires a main-actor hop.

URLSession redirect delegate

URLSessionTaskDelegate cannot use an OAuth2Actor-isolated conformance because Foundation invokes delegate witnesses from its delegate queue and the protocol has sendability requirements. The delegate is therefore a sendable boundary object with immutable state. Redirect validation, logging, and request signing are captured in an @OAuth2Actor @Sendable closure and awaited from the Foundation callback.

This preserves the existing behavior:

  • cross-host redirects are rejected;
  • same-host redirects are re-signed;
  • signing failures fall back to the original request;
  • the loader remains weakly captured.

No new nonisolated declaration is introduced. The existing OAuth2AuthConfig.authorizeContext declaration remains unchanged.

Platform presentation

The iOS and tvOS custom authorizers now expose async presentation methods and await UIKit presentation on the main actor, matching the existing async protocol requirement. Dismissal remains fire-and-forget but performs UIKit work through a task.

Tests

Swift 6 XCTest aborts when synchronous XCTest discovery directly invokes a custom-global-actor-isolated test method. Actor-isolated test entry points are now async so XCTest uses its async executor-aware path. Test response dictionaries that cross actor boundaries use [String: any Sendable].

Verification

Completed locally with Xcode 26.6 / Swift 6.3.3 while targeting the Swift 6.2 manifest and Swift 6 language mode:

  • swift package reset
  • swift build
  • swift test — 59 tests passed
  • macOS Xcode build — passed
  • macOS Xcode tests — passed
  • Mac Catalyst Xcode build for the iOS target — passed
  • git diff --check — passed

CI is configured to validate with Xcode 26 and its Swift 6.2 toolchain.

@DominikPalo DominikPalo mentioned this pull request Sep 10, 2026
@DominikPalo

Copy link
Copy Markdown
Member Author

One runtime concern remains uncertain because the task-ordering path could not be reproduced.

Set aside
  • dismissLoginController(animated:) may clear state for a newer iOS or tvOS presentation. We set this aside because the required ordering check timed out and no isolated runtime proof is available.
Review context
  • Decision reason: A high-severity ordering concern could not be reproduced, and the proposed fix path needs more work.
  • Result: No confirmed actionable findings; one high-severity runtime concern was set aside.
  • Scope: Migrate OAuth2 to Swift 6.2 and Swift 6 language mode with focused concurrency, test, documentation, and CI changes.
  • Target: PR Migrate to Swift 6.2 #51 (codex/migrate-to-swift-6.2, 20 files, +278/-199) at c731e60230110aea8b69d6ad6df4d67399693a97.
  • Run ordinal: 1
  • Rounds: 1/1; review-only.
  • Reviewers: 2 codex-exec + 1 claude-exec; 1 completed and 2 timed out.
  • Checks: 1 concern required checking; the verifier timed out, so 1 concern was set aside.
  • Second check: targeted; 1 reviewer completed, 1 timed out; the completed check found the proposed change incomplete.
  • Clarity pass: The renderer returned non-protocol output twice, so this report uses the exact-source fallback.
  • Fixes applied: 0 (review-only).

Reviewed with review-anvil.

Raise the package tools version, enable Swift 6 language mode in the Xcode project, and refresh the resolved package format.
Keep web authentication session state on the main actor and await platform UI presentation across iOS, macOS, and tvOS.
Keep the URLSession delegate callback nonisolated and bridge redirect decisions to OAuth2Actor through an immutable Sendable closure.
Run actor-isolated XCTest methods asynchronously and mark cross-actor dictionary values as Sendable.
Document the new minimum toolchain and run package and Xcode jobs with Swift 6.2.
Select installed simulator devices for iOS and tvOS, use an Xcode 26 release with both runtimes, and update xcresulttool for Xcode 26 support.
@DominikPalo
DominikPalo force-pushed the codex/migrate-to-swift-6.2 branch from c731e60 to 172d411 Compare September 16, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Swift 6.2 compatibility

1 participant