Skip to content

feat: add @Sendable annotations to closure parameters for Swift 6 compliance#1128

Merged
sanchitmehtagit merged 1 commit intodevelop/v3.0from
feat/swift6-sendable-closure-parameters
Mar 26, 2026
Merged

feat: add @Sendable annotations to closure parameters for Swift 6 compliance#1128
sanchitmehtagit merged 1 commit intodevelop/v3.0from
feat/swift6-sendable-closure-parameters

Conversation

@sanchitmehtagit
Copy link
Copy Markdown
Contributor

Motivation

Swift 6 strict concurrency requires closures that escape across
concurrency boundaries to be @Sendable. Without this, the compiler
emits warnings (Swift 5 mode) or errors (Swift 6 mode) when SDK
callbacks are passed into DispatchQueue.async, Task, or any
other concurrent context — which is exactly how the SDK uses them
internally (e.g. dispatchOnMain, SynchronizationBarrier,
IDTokenValidator).

This brings the callback-based public API into line with Swift 6
strict concurrency, matching the scope of #1095, and ensures users
adopting Swift 6 don't encounter unexpected compiler errors at their
call sites.

Summary

  • Add @Sendable to all escaping closure/callback parameters across
    the public API and internal SDK utilities
  • Fix the Requestable mocking example in V3_MIGRATION_GUIDE.md
    which was no longer valid against the updated protocol
  • Add a new @sendable callback parameters section to the Swift 6
    Concurrency chapter of the migration guide, clarifying that only
    custom protocol implementations (mocks/test doubles) require changes

Files changed

File Change
Request.swift Callback typealias + handle property → @Sendable
Requestable.swift start(_:) callback → @Sendable
WebAuth.swift onClose, start, logout callbacks → @Sendable
Auth0WebAuth.swift onCloseCallback property + onClose, start, logout@Sendable
IDTokenValidator.swift JWTAsyncValidator protocol + implementations → @Sendable
IDTokenSignatureValidator.swift validate(_:callback:)@Sendable
SynchronizationBarrier.swift pendingOperations + execute(_:)@Sendable
OAuth2Grant.swift credentials(from:callback:)@Sendable
LoginTransaction.swift FinishTransaction typealias → @Sendable
Shared.swift dispatchOnMain input + return types → @Sendable
CredentialsManager.swift All public/private callback parameters → @Sendable
V3_MIGRATION_GUIDE.md New section + mocking example fix

Test plan

  • Build succeeds with SWIFT_STRICT_CONCURRENCY = complete
  • Existing tests pass without modification
  • No new warnings introduced under Swift 6 mode

@sanchitmehtagit sanchitmehtagit requested a review from a team as a code owner March 26, 2026 11:25
@sanchitmehtagit sanchitmehtagit added Swift v3.0 This label depicts this feature is part of Swift 3.0 review:medium Medium review Swift 6 compliance PR meany for Swift 6 strict concurrency compliance labels Mar 26, 2026
@sanchitmehtagit sanchitmehtagit changed the title feat: add @Sendable annotations to closure parameters for Swift 6 com… feat: add @Sendable annotations to closure parameters for Swift 6 compliance Mar 26, 2026
@sanchitmehtagit sanchitmehtagit force-pushed the feat/swift6-sendable-closure-parameters branch from eba2f48 to 792eac5 Compare March 26, 2026 11:29
@sanchitmehtagit sanchitmehtagit merged commit 932057d into develop/v3.0 Mar 26, 2026
12 checks passed
@sanchitmehtagit sanchitmehtagit deleted the feat/swift6-sendable-closure-parameters branch March 26, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:medium Medium review Swift v3.0 This label depicts this feature is part of Swift 3.0 Swift 6 compliance PR meany for Swift 6 strict concurrency compliance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants