Skip to content

Commit

Permalink
Xcode 13: remove conditional code (#3147)
Browse files Browse the repository at this point in the history
Clean up thanks to #2421
  • Loading branch information
NachoSoto authored Sep 6, 2023
1 parent 7d8f0e0 commit 8243593
Show file tree
Hide file tree
Showing 21 changed files with 0 additions and 189 deletions.
56 changes: 0 additions & 56 deletions Package@swift-5.6.swift

This file was deleted.

7 changes: 0 additions & 7 deletions Sources/Identity/CustomerInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,7 @@ extension CustomerInfo: RawDataContainer {

}

#if swift(>=5.7)
extension CustomerInfo: Sendable {}
#else
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
// - `URL` is not `Sendable` until Swift 5.7
extension CustomerInfo: @unchecked Sendable {}
#endif

/// `CustomerInfo`'s `Codable` implementation relies on `Data`
extension CustomerInfo: Codable {
Expand Down
6 changes: 0 additions & 6 deletions Sources/LocalReceiptParsing/BasicTypes/AppleReceipt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ public struct AppleReceipt: Equatable {

}

#if swift(>=5.7)
extension AppleReceipt: Sendable {}
#else
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
extension AppleReceipt: @unchecked Sendable {}
#endif

// MARK: - Extensions

Expand Down
6 changes: 0 additions & 6 deletions Sources/LocalReceiptParsing/BasicTypes/InAppPurchase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,7 @@ extension AppleReceipt.InAppPurchase {

extension AppleReceipt.InAppPurchase.ProductType: Sendable {}

#if swift(>=5.7)
extension AppleReceipt.InAppPurchase: Sendable {}
#else
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
extension AppleReceipt.InAppPurchase: @unchecked Sendable {}
#endif

extension AppleReceipt.InAppPurchase.ProductType: Codable {}
extension AppleReceipt.InAppPurchase: Codable {}
Expand Down
10 changes: 0 additions & 10 deletions Sources/Misc/Concurrency/Lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ internal final class Lock {

}

#if swift(>=5.7)
private typealias UnderlyingType = NSLocking & Sendable
#else
// `NSRecursiveLock` and `NSLock` aren't `Sendable` until iOS 16.0 / Swift 5.7
private typealias UnderlyingType = NSLocking
#endif

private let lock: UnderlyingType
private init(_ lock: UnderlyingType) { self.lock = lock }
Expand All @@ -51,12 +46,7 @@ internal final class Lock {

}

#if swift(>=5.7)
extension Lock: Sendable {}
#else
// `Lock.UnderlyingType` isn't `Sendable` until Swift 5.7
extension Lock: @unchecked Sendable {}
#endif

private extension Lock.LockType {

Expand Down
12 changes: 0 additions & 12 deletions Sources/Misc/SystemInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ private extension SystemInfo {
return Bundle.main.infoDictionary?.keys.contains("WKApplication") == true
}

// In Xcode 14 and later, you can produce watchOS apps with a single watchOS app target.
// These single-target watchOS apps can run on watchOS 7 and later.
#if swift(>=5.7)
if #available(watchOS 7.0, *), self.isOperatingSystemAtLeast(.init(majorVersion: 9,
minorVersion: 0,
patchVersion: 0)) {
Expand All @@ -288,15 +285,6 @@ private extension SystemInfo {
return WKExtension.shared().applicationState == .background
}
}
#else
// In Xcode 13 and earlier the system divides a watchOS app into two sections
// (single-target apps are not supported):
// - WatchKit app
// - WatchKit extension

// Before Xcode 14, single-target extensions aren't supported (and `WKApplication` isn't available)
return WKExtension.shared().applicationState == .background
#endif
}

#endif
Expand Down
5 changes: 0 additions & 5 deletions Sources/Purchasing/CachingProductsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ final class CachingProductsManager {
private let productCache: Atomic<[String: StoreProduct]> = .init([:])
private let requestCache: Atomic<[Set<String>: [Completion]]> = .init([:])

#if swift(>=5.7)
private let _sk2ProductCache: (any Sendable)?
private let _sk2RequestCache: (any Sendable)?
#else
private let _sk2ProductCache: Any?
private let _sk2RequestCache: Any?
#endif

@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
private var sk2ProductCache: Atomic<[String: SK2StoreProduct]> {
Expand Down
6 changes: 0 additions & 6 deletions Sources/Purchasing/EntitlementInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,4 @@ private extension EntitlementInfo {

}

#if swift(>=5.7)
extension EntitlementInfo.Contents: Sendable {}
#else
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
extension EntitlementInfo.Contents: @unchecked Sendable {}
#endif
6 changes: 0 additions & 6 deletions Sources/Purchasing/NonSubscriptionTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,4 @@ public final class NonSubscriptionTransaction: NSObject {

}

#if swift(>=5.7)
extension NonSubscriptionTransaction: Sendable {}
#else
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
extension NonSubscriptionTransaction: @unchecked Sendable {}
#endif
4 changes: 0 additions & 4 deletions Sources/Purchasing/ProductsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ class ProductsManager: NSObject, ProductsManagerType {
private let productsFetcherSK1: ProductsFetcherSK1
private let systemInfo: SystemInfo

#if swift(>=5.7)
private let _productsFetcherSK2: (any Sendable)?
#else
private let _productsFetcherSK2: Any?
#endif

@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
private var productsFetcherSK2: ProductsFetcherSK2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,9 @@ actor StoreKit2TransactionListener: StoreKit2TransactionListenerType {
private weak var delegate: StoreKit2TransactionListenerDelegate?
private let updates: AsyncStream<TransactionResult>

#if swift(<5.7)
// Note that these 2 constructors are duplicated because
// not having convinience here is an error in Xcode 13
// But having it is an error in Xcode 14.
convenience init(delegate: StoreKit2TransactionListenerDelegate? = nil) {
self.init(delegate: delegate, updates: StoreKit.Transaction.updates)
}
#else
init(delegate: StoreKit2TransactionListenerDelegate? = nil) {
self.init(delegate: delegate, updates: StoreKit.Transaction.updates)
}
#endif

/// Creates a listener with an `AsyncSequence` of `VerificationResult<Transaction>`s
/// By default `StoreKit.Transaction.updates` is used, but a custom one can be passed for testing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ extension PromotionalOffer: Sendable {}

}

#if swift(>=5.7)
extension PromotionalOffer.SignedData: Sendable {}
#else
// `@unchecked` because:
// - `UUID` is not `Sendable` until Swift 5.7
extension PromotionalOffer.SignedData: @unchecked Sendable {}
#endif

extension PromotionalOffer.SignedData {

Expand Down
5 changes: 0 additions & 5 deletions Sources/Purchasing/StoreKitAbstractions/SK1StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,3 @@ extension SK1StoreProduct: Hashable {
}

}

#if swift(<5.7)
// `SK1Product` isn't `Sendable` until iOS 16.0 / Swift 5.7
extension SK1StoreProduct: @unchecked Sendable {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ internal struct SK1StoreProductDiscount: StoreProductDiscountType {

}

#if swift(<5.7)
// `SK1ProductDiscount` isn't `Sendable` until iOS 16.0 / Swift 5.7
@available(iOS 11.2, macOS 10.13.2, tvOS 11.2, watchOS 6.2, *)
extension SK1StoreProductDiscount: @unchecked Sendable {}
#endif

// MARK: - Private

private extension StoreProductDiscount.PaymentMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,3 @@ extension SKPaymentTransaction {
}

}

#if swift(<5.7)
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
// - `SK1Transaction` is not `Sendable` until Swift 5.7
extension SK1StoreTransaction: @unchecked Sendable {}
#endif
6 changes: 0 additions & 6 deletions Sources/Purchasing/StoreKitAbstractions/SK1Storefront.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,3 @@ internal struct SK1Storefront: StorefrontType {
let countryCode: String

}

#if swift(<5.7)
// `SKStorefront` isn't `Sendable` until iOS 16.0 / Swift 5.7
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, macCatalyst 13.1, *)
extension SK1Storefront: @unchecked Sendable {}
#endif
6 changes: 0 additions & 6 deletions Sources/Purchasing/StoreKitAbstractions/SK2StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,3 @@ extension SK2StoreProduct: Hashable {
}

}

#if swift(<5.7)
// `SK2Product` isn't `Sendable` until iOS 16.0 / Swift 5.7
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
extension SK2StoreProduct: @unchecked Sendable {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ internal struct SK2StoreProductDiscount: StoreProductDiscountType {
var localizedPriceString: String { underlyingSK2Discount.displayPrice }
}

#if swift(<5.7)
// `SK2ProductDiscount` isn't `Sendable` until iOS 16.0 / Swift 5.7
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
extension SK2StoreProductDiscount: @unchecked Sendable {}
#endif

// MARK: - Private

private extension StoreProductDiscount.PaymentMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,3 @@ internal struct SK2StoreTransaction: StoreTransactionType {
}

}

#if swift(<5.7)
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
// - `SK2Transaction` is not `Sendable` until Swift 5.7
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
extension SK2StoreTransaction: @unchecked Sendable {}
#endif
6 changes: 0 additions & 6 deletions Sources/Purchasing/StoreKitAbstractions/SK2Storefront.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,3 @@ internal struct SK2Storefront: StorefrontType {
let countryCode: String

}

#if swift(<5.7)
// `SKStorefront` isn't `Sendable` until iOS 16.0 / Swift 5.7
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
extension SK2Storefront: @unchecked Sendable {}
#endif
6 changes: 0 additions & 6 deletions Tests/UnitTests/Mocks/MockStoreTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,3 @@ final class MockStoreTransaction: StoreTransactionType {
}

}

#if swift(<5.7)
// `@unchecked` because:
// - `Date` is not `Sendable` until Swift 5.7
extension MockStoreTransaction: @unchecked Sendable {}
#endif

0 comments on commit 8243593

Please sign in to comment.