Skip to content

bug: CAPSceneDelegateProxy mutates token after capture by a sendable closure #8662

Open

Description

@walljm

Capacitor Version

@capacitor/core 8.5.2
@capacitor/ios 8.5.2

Also present in 8.5.3.

Platforms Affected

  • iOS

Current Behavior

Building an iOS app with Xcode 27 (27A266a) reports:

Capacitor/CAPSceneDelegateProxy.swift:24: warning: 'token' mutated after capture by sendable closure

scene(_:willConnectTo:options:) declares var token, captures it in the addObserver(forName:object:queue:using:) block (which is @Sendable), then assigns to it after the capture. It works at runtime because the block runs on the main queue after the assignment, but the compiler can't see that, and under Swift 6 language mode this is an error.

Expected Behavior

No warning. Holding the token in a small reference box captured by the closure, or using a one-shot Task over NotificationCenter.default.notifications(named: .capacitorViewDidAppear), avoids mutating a captured variable.

Project Reproduction

Any Capacitor 8.5.x iOS app built with Xcode 27 shows it. The warning comes from the shipped CAPSceneDelegateProxy.swift, so no app code is involved.

Additional Information

Seen in Xcode Cloud archive builds on macOS 27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions