@@ -341,8 +341,8 @@ public final class OpenIapModule: NSObject, OpenIapModuleProtocol {
341341 do {
342342 // iOS 17.0+, tvOS 17.0+, macOS 15.2+: Use purchase(confirmIn:options:) for better purchase confirmation UI
343343 // Reference: https://developer.apple.com/documentation/storekit/product/purchase(confirmin:options:)-6dj6y
344- #if os(iOS) || os(tvOS )
345- // iOS/tvOS: Use UIWindowScene (not available on watchOS)
344+ #if canImport(UIKit )
345+ // iOS/tvOS: Use UIWindowScene
346346 if #available( iOS 17 . 0 , tvOS 17 . 0 , * ) {
347347 let scene : UIWindowScene ? = await MainActor . run {
348348 UIApplication . shared. connectedScenes. first as? UIWindowScene
@@ -356,7 +356,7 @@ public final class OpenIapModule: NSObject, OpenIapModuleProtocol {
356356 } else {
357357 result = try await product. purchase ( options: options)
358358 }
359- #elseif os(macOS )
359+ #elseif canImport(AppKit )
360360 // macOS: Use NSWindow (macOS 15.2+)
361361 if #available( macOS 15 . 2 , * ) {
362362 let window : NSWindow ? = await MainActor . run {
@@ -1066,15 +1066,15 @@ public final class OpenIapModule: NSObject, OpenIapModuleProtocol {
10661066 /// - SeeAlso: https://developer.apple.com/documentation/storekit/skpaymentqueue/3566726-presentcoderedemptionsheet
10671067 public func presentCodeRedemptionSheetIOS( ) async throws -> Bool {
10681068 try await ensureConnection ( )
1069- // presentCodeRedemptionSheet is only available on iOS, not tvOS/watchOS/macOS
1070- #if os(iOS )
1069+ // tvOS: SKPaymentQueue. presentCodeRedemptionSheet explicitly unavailable on tvOS
1070+ #if canImport(UIKit) && ! os(tvOS )
10711071 await MainActor . run {
10721072 SKPaymentQueue . default ( ) . presentCodeRedemptionSheet ( )
10731073 }
10741074 return true
10751075 #else
10761076 throw makePurchaseError ( code: . featureNotSupported)
1077- #endif // os(iOS )
1077+ #endif // canImport(UIKit) && ! os(tvOS )
10781078 }
10791079
10801080 public func showManageSubscriptionsIOS( ) async throws -> [ PurchaseIOS ] {
@@ -1159,9 +1159,9 @@ public final class OpenIapModule: NSObject, OpenIapModuleProtocol {
11591159
11601160 public func presentExternalPurchaseLinkIOS( _ url: String ) async throws -> ExternalPurchaseLinkResultIOS {
11611161 try await ensureConnection ( )
1162- // UIApplication.open is available on iOS/tvOS/visionOS but not watchOS/macOS
1162+ // UIKit platforms: Open external link using UIApplication.open
11631163 // Reference: https://developer.apple.com/documentation/uikit/uiapplication/1648685-open
1164- #if os(iOS) || os(tvOS) || os(visionOS )
1164+ #if canImport(UIKit )
11651165 guard let customLink = URL ( string: url) else {
11661166 return ExternalPurchaseLinkResultIOS (
11671167 error: " Invalid URL " ,
@@ -1184,7 +1184,7 @@ public final class OpenIapModule: NSObject, OpenIapModuleProtocol {
11841184 }
11851185 #else
11861186 throw makePurchaseError ( code: . featureNotSupported)
1187- #endif // os(iOS) || os(tvOS) || os(visionOS )
1187+ #endif // canImport(UIKit )
11881188 }
11891189
11901190 // MARK: - ExternalPurchaseCustomLink (iOS 18.1+)
0 commit comments