Skip to content

Conversation

mehmetbaykar
Copy link
Contributor

Fix Xcode 26.0 Swift Concurrency error

What

  • Refactor LinkPreview to use Swift Concurrency.

  • Fetch metadata with async/await and set LPLinkView.metadata on the main actor:

    • Task { @MainActor in uiView.metadata = try await fetchMetadata() }
    • Introduce fetchMetadata() async throws -> LPLinkMetadata.

Why

  • In Xcode 26.0 with stricter concurrency checks, the previous completion-handler approach attempted to set uiView.metadata (a @MainActor-isolated property) from a @Sendable/background context, triggering:
    “Main actor-isolated property 'metadata' cannot be mutated from a Sendable closure.”
  • Using async/await removes the sendable-closure issue and guarantees UI updates occur on the main actor, aligning with Swift 6 concurrency rules.

Affected Areas

  • LinkPreview.swift only.
  • No behavioral change to the UI; thread-safety and compile-time correctness improved.
  • Note: Requires async/await (iOS 15+/macOS 12+).

Fix xCode 26.0 Swift Concurrency error.
Copy link
Collaborator

@nezhyborets nezhyborets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@nezhyborets nezhyborets merged commit a6e2f87 into MacPaw:main Sep 15, 2025
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.

2 participants