Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @MainActor reference in unsupported OS versions #4612

Draft
wants to merge 1 commit into
base: release/4.43.3
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Sources/Purchasing/Purchases/Purchases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ public typealias PurchaseResultData = (transaction: StoreTransaction?,
/**
Completion block for ``Purchases/purchase(product:completion:)``
*/
#if swift(>=5.5) && canImport(_Concurrency)
Copy link
Member Author

@aboedo aboedo Dec 19, 2024

Choose a reason for hiding this comment

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

I believe the swift concurrency import check would work

Copy link
Member

Choose a reason for hiding this comment

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

I think since this is a compiler conditional, canImport only checks if the version of Xcode you're compiling with supports concurrency.

And since @MainActor is supposedly back ported to macOS 10/11, and the current version of Xcode supports concurrency, this means we would end up always compiling the first branch.

public typealias PurchaseCompletedBlock = @MainActor @Sendable (StoreTransaction?,
CustomerInfo?,
PublicError?,
Bool) -> Void

#else
// OS versions that don't support Swift Concurrency can't have references to Swift Concurrency types like @MainActor
public typealias PurchaseCompletedBlock = (StoreTransaction?,
CustomerInfo?,
PublicError?,
Bool) -> Void
#endif
/**
Block for starting purchases in ``PurchasesDelegate/purchases(_:readyForPromotedProduct:purchase:)``
*/
Expand Down