Skip to content

Conversation

@abelonogov-ld
Copy link

@abelonogov-ld abelonogov-ld commented Oct 14, 2025

Requirements

  • I have added test coverage for new or changed functionality
    Tests can not be added, package doesn't compiles under Swift6

  • I have followed the repository's pull request submission guidelines

  • [x ] I have validated my changes against all supported platform versions
    Test on different XCode versions using both Swift5 and Swift6

Describe the solution you've provided

Fixes crash of using not main-thread completions called from Swift6 application

  • Annotates all non-main closures in the public method as @sendable.
    It removes crash, but might add compiler warning or compilation error if body of closure uses UI code.

Describe alternatives you've considered

Run all completions on the main thread. Didn't make because it would change existing behavior, which might be provided in big version update.

Additional context

use @preconcurrency import LaunchDarkly if you want to turn related compiler errors into warnings

Proof of testing
image


Note

Annotates public completion/handler closures with @sendable for Swift 6 compatibility and updates docs (main-thread notes) plus README guidance to use @preconcurrency import.

  • API/Concurrency:
    • Mark @Sendable on public callbacks in LDClient.swift:
      • setOnline(_:completion:)
      • identify(context:completion:) (deprecated) and all identify overloads (including useCache: and timeout: variants)
      • start(config:context:completion:) and start(... startWaitSeconds: ... completion:)
  • Docs:
    • Clarify parameter docs that observe handlers execute on the main thread in LDClient.swift (observe, observe(keys:), observeAll, observeFlagsUnchanged, observeCurrentConnectionMode).
  • README:
    • Add Swift 6 note to use @preconcurrency import LaunchDarkly to mitigate compilation issues.

Written by Cursor Bugbot for commit 1c5c111. This will update automatically on new commits. Configure here.

…pplication

- Marks all non-main closures in public method as @sendable.
It removes crash, but might add compiler warning if body closure uses UI.

use `@preconcurrency import LaunchDarkly` if you want to turn these compiler errors into warnings (+1 squashed commit)
Squashed commits:
[6dea698] reverse
@abelonogov-ld abelonogov-ld requested a review from a team as a code owner October 14, 2025 23:01
@abelonogov-ld abelonogov-ld changed the title Andrey/ldclient swift6 fix fix! Fix crash calling API with non main thread completions from Swift6 Oct 14, 2025
@abelonogov-ld abelonogov-ld changed the title fix! Fix crash calling API with non main thread completions from Swift6 fix! Fix crash calling API with non-main thread completions from Swift6 Oct 14, 2025
@abelonogov-ld abelonogov-ld changed the title fix! Fix crash calling API with non-main thread completions from Swift6 fix: Fix crash calling API with non-main thread completions from Swift6 Oct 14, 2025
@ThrownToys
Copy link

I've given this a go, and it seems to have fixed the crash I was seeing. Thanks for moving on this - LGTM

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.

4 participants