Rename to LocalProduct to avoid StoreKit clash

Started happening with Xcode 13.
This commit is contained in:
Davide De Rosa 2021-09-27 17:59:01 +02:00
parent a90cf31974
commit d1a1b555f8
11 changed files with 67 additions and 67 deletions

View File

@ -127,7 +127,7 @@
0E5204C4259F675400CBAB56 /* TrustPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */; }; 0E5204C4259F675400CBAB56 /* TrustPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */; };
0E5204C5259F675400CBAB56 /* ProviderConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */; }; 0E5204C5259F675400CBAB56 /* ProviderConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */; };
0E5204C6259F675400CBAB56 /* Pool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C0F20CF09A30027975F /* Pool.swift */; }; 0E5204C6259F675400CBAB56 /* Pool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C0F20CF09A30027975F /* Pool.swift */; };
0E5204C7259F675400CBAB56 /* Product.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F1B259F2D8F0022DFB8 /* Product.swift */; }; 0E5204C7259F675400CBAB56 /* Feature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F1B259F2D8F0022DFB8 /* Feature.swift */; };
0E5204C8259F675400CBAB56 /* PoolGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E533B152258E03B00EF94FC /* PoolGroup.swift */; }; 0E5204C8259F675400CBAB56 /* PoolGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E533B152258E03B00EF94FC /* PoolGroup.swift */; };
0E5204C9259F675400CBAB56 /* ConnectionService+Configurations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E2D11B9217DBEDE0096822C /* ConnectionService+Configurations.swift */; }; 0E5204C9259F675400CBAB56 /* ConnectionService+Configurations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E2D11B9217DBEDE0096822C /* ConnectionService+Configurations.swift */; };
0E5204CA259F675400CBAB56 /* ProfileNetworkSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFB901722764689006405E4 /* ProfileNetworkSettings.swift */; }; 0E5204CA259F675400CBAB56 /* ProfileNetworkSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFB901722764689006405E4 /* ProfileNetworkSettings.swift */; };
@ -157,7 +157,7 @@
0E569F15259F2D3E0022DFB8 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F14259F2D3E0022DFB8 /* Issue.swift */; }; 0E569F15259F2D3E0022DFB8 /* Issue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F14259F2D3E0022DFB8 /* Issue.swift */; };
0E569F1C259F2D8F0022DFB8 /* GracefulVPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F19259F2D8F0022DFB8 /* GracefulVPN.swift */; }; 0E569F1C259F2D8F0022DFB8 /* GracefulVPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F19259F2D8F0022DFB8 /* GracefulVPN.swift */; };
0E569F1E259F2D8F0022DFB8 /* ProductManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F1A259F2D8F0022DFB8 /* ProductManager.swift */; }; 0E569F1E259F2D8F0022DFB8 /* ProductManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F1A259F2D8F0022DFB8 /* ProductManager.swift */; };
0E569F20259F2D8F0022DFB8 /* Product.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F1B259F2D8F0022DFB8 /* Product.swift */; }; 0E569F20259F2D8F0022DFB8 /* Feature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F1B259F2D8F0022DFB8 /* Feature.swift */; };
0E569F2B259F2DB10022DFB8 /* Infrastructure+Name.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F28259F2DB10022DFB8 /* Infrastructure+Name.swift */; }; 0E569F2B259F2DB10022DFB8 /* Infrastructure+Name.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F28259F2DB10022DFB8 /* Infrastructure+Name.swift */; };
0E569F2C259F2DB10022DFB8 /* Infrastructure+Metadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F29259F2DB10022DFB8 /* Infrastructure+Metadata.swift */; }; 0E569F2C259F2DB10022DFB8 /* Infrastructure+Metadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F29259F2DB10022DFB8 /* Infrastructure+Metadata.swift */; };
0E569F2D259F2DB10022DFB8 /* InfrastructureFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F2A259F2DB10022DFB8 /* InfrastructureFactory.swift */; }; 0E569F2D259F2DB10022DFB8 /* InfrastructureFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E569F2A259F2DB10022DFB8 /* InfrastructureFactory.swift */; };
@ -408,7 +408,7 @@
0E569F14259F2D3E0022DFB8 /* Issue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Issue.swift; sourceTree = "<group>"; }; 0E569F14259F2D3E0022DFB8 /* Issue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Issue.swift; sourceTree = "<group>"; };
0E569F19259F2D8F0022DFB8 /* GracefulVPN.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GracefulVPN.swift; sourceTree = "<group>"; }; 0E569F19259F2D8F0022DFB8 /* GracefulVPN.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GracefulVPN.swift; sourceTree = "<group>"; };
0E569F1A259F2D8F0022DFB8 /* ProductManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductManager.swift; sourceTree = "<group>"; }; 0E569F1A259F2D8F0022DFB8 /* ProductManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductManager.swift; sourceTree = "<group>"; };
0E569F1B259F2D8F0022DFB8 /* Product.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Product.swift; sourceTree = "<group>"; }; 0E569F1B259F2D8F0022DFB8 /* Feature.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Feature.swift; sourceTree = "<group>"; };
0E569F28259F2DB10022DFB8 /* Infrastructure+Name.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Infrastructure+Name.swift"; sourceTree = "<group>"; }; 0E569F28259F2DB10022DFB8 /* Infrastructure+Name.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Infrastructure+Name.swift"; sourceTree = "<group>"; };
0E569F29259F2DB10022DFB8 /* Infrastructure+Metadata.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Infrastructure+Metadata.swift"; sourceTree = "<group>"; }; 0E569F29259F2DB10022DFB8 /* Infrastructure+Metadata.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Infrastructure+Metadata.swift"; sourceTree = "<group>"; };
0E569F2A259F2DB10022DFB8 /* InfrastructureFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfrastructureFactory.swift; sourceTree = "<group>"; }; 0E569F2A259F2DB10022DFB8 /* InfrastructureFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfrastructureFactory.swift; sourceTree = "<group>"; };
@ -1011,10 +1011,10 @@
0ECEB109224FECEA00E9E551 /* DataUnit.swift */, 0ECEB109224FECEA00E9E551 /* DataUnit.swift */,
0EC7F20420E24308004EA58E /* DebugLog.swift */, 0EC7F20420E24308004EA58E /* DebugLog.swift */,
0ED38AE621404F100004D387 /* EndpointDataSource.swift */, 0ED38AE621404F100004D387 /* EndpointDataSource.swift */,
0E569F1B259F2D8F0022DFB8 /* Feature.swift */,
0E569F19259F2D8F0022DFB8 /* GracefulVPN.swift */, 0E569F19259F2D8F0022DFB8 /* GracefulVPN.swift */,
0E45E70F22BE108100F19312 /* OpenVPNOptions.swift */, 0E45E70F22BE108100F19312 /* OpenVPNOptions.swift */,
0E89DFC4213DF7AE00741BA1 /* Preferences.swift */, 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */,
0E569F1B259F2D8F0022DFB8 /* Product.swift */,
0E569F1A259F2D8F0022DFB8 /* ProductManager.swift */, 0E569F1A259F2D8F0022DFB8 /* ProductManager.swift */,
0EFB901722764689006405E4 /* ProfileNetworkSettings.swift */, 0EFB901722764689006405E4 /* ProfileNetworkSettings.swift */,
0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */, 0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */,
@ -1865,7 +1865,7 @@
0E3152C0223FA03D00F61841 /* Utils.swift in Sources */, 0E3152C0223FA03D00F61841 /* Utils.swift in Sources */,
0E3152CB223FA04D00F61841 /* Pool.swift in Sources */, 0E3152CB223FA04D00F61841 /* Pool.swift in Sources */,
0E3CAFC0229AAE770008E5C8 /* Intents.intentdefinition in Sources */, 0E3CAFC0229AAE770008E5C8 /* Intents.intentdefinition in Sources */,
0E569F20259F2D8F0022DFB8 /* Product.swift in Sources */, 0E569F20259F2D8F0022DFB8 /* Feature.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -1964,7 +1964,7 @@
0E5204CD259F675400CBAB56 /* Infrastructure+Name.swift in Sources */, 0E5204CD259F675400CBAB56 /* Infrastructure+Name.swift in Sources */,
0E5204CC259F675400CBAB56 /* HostConnectionProfile.swift in Sources */, 0E5204CC259F675400CBAB56 /* HostConnectionProfile.swift in Sources */,
0E5204B7259F674000CBAB56 /* AppConstants.swift in Sources */, 0E5204B7259F674000CBAB56 /* AppConstants.swift in Sources */,
0E5204C7259F675400CBAB56 /* Product.swift in Sources */, 0E5204C7259F675400CBAB56 /* Feature.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -64,7 +64,7 @@ extension UIColor {
} }
extension UIViewController { extension UIViewController {
func presentPurchaseScreen(forProduct product: Product, delegate: PurchaseViewControllerDelegate? = nil) { func presentPurchaseScreen(forProduct product: LocalProduct, delegate: PurchaseViewControllerDelegate? = nil) {
let nav = StoryboardScene.Purchase.initialScene.instantiate() let nav = StoryboardScene.Purchase.initialScene.instantiate()
let vc = nav.topViewController as? PurchaseViewController let vc = nav.topViewController as? PurchaseViewController
// vc?.feature = product // vc?.feature = product

View File

@ -32,7 +32,7 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self
class DonationViewController: UITableViewController, StrongTableHost { class DonationViewController: UITableViewController, StrongTableHost {
private var donationList: [Product] = [] private var donationList: [LocalProduct] = []
private var productsByIdentifier: [String: SKProduct] = [:] private var productsByIdentifier: [String: SKProduct] = [:]
@ -65,7 +65,7 @@ class DonationViewController: UITableViewController, StrongTableHost {
return return
} }
donationList.append(contentsOf: Product.allDonations.filter { productsByIdentifier[$0.rawValue] != nil }) donationList.append(contentsOf: LocalProduct.allDonations.filter { productsByIdentifier[$0.rawValue] != nil })
model.set(.donation, count: donationList.count, forSection: .oneTime) model.set(.donation, count: donationList.count, forSection: .oneTime)
if isPurchasing { if isPurchasing {

View File

@ -230,7 +230,7 @@ extension WizardProviderViewController: AccountViewControllerDelegate {
// MARK: - // MARK: -
extension WizardProviderViewController: PurchaseViewControllerDelegate { extension WizardProviderViewController: PurchaseViewControllerDelegate {
func purchaseController(_ purchaseController: PurchaseViewController, didPurchase product: Product?) { func purchaseController(_ purchaseController: PurchaseViewController, didPurchase product: LocalProduct?) {
guard let metadata = selectedMetadata else { guard let metadata = selectedMetadata else {
return return
} }

View File

@ -32,13 +32,13 @@ import Convenience
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self
protocol PurchaseViewControllerDelegate: AnyObject { protocol PurchaseViewControllerDelegate: AnyObject {
func purchaseController(_ purchaseController: PurchaseViewController, didPurchase product: Product?) func purchaseController(_ purchaseController: PurchaseViewController, didPurchase product: LocalProduct?)
} }
class PurchaseViewController: UITableViewController, StrongTableHost { class PurchaseViewController: UITableViewController, StrongTableHost {
private var isLoading = true private var isLoading = true
var feature: Product? var feature: LocalProduct?
weak var delegate: PurchaseViewControllerDelegate? weak var delegate: PurchaseViewControllerDelegate?
@ -162,7 +162,7 @@ class PurchaseViewController: UITableViewController, StrongTableHost {
guard let weakSelf = self else { guard let weakSelf = self else {
return return
} }
let product = Product(rawValue: skProduct.productIdentifier) let product = LocalProduct(rawValue: skProduct.productIdentifier)
weakSelf.delegate?.purchaseController(weakSelf, didPurchase: product) weakSelf.delegate?.purchaseController(weakSelf, didPurchase: product)
} }
} }

View File

@ -91,7 +91,7 @@ extension NSAlert {
} }
extension NSViewController { extension NSViewController {
func presentPurchaseScreen(forProduct product: Product, delegate: PurchaseViewControllerDelegate? = nil) { func presentPurchaseScreen(forProduct product: LocalProduct, delegate: PurchaseViewControllerDelegate? = nil) {
let vc = StoryboardScene.Purchase.initialScene.instantiate() let vc = StoryboardScene.Purchase.initialScene.instantiate()
// vc.feature = product // vc.feature = product
vc.delegate = delegate vc.delegate = delegate

View File

@ -580,7 +580,7 @@ class StatusMenu: NSObject {
private func addDonations(fromProducts products: [SKProduct], to menu: NSMenu) { private func addDonations(fromProducts products: [SKProduct], to menu: NSMenu) {
products.sorted { $0.price.decimalValue < $1.price.decimalValue }.forEach { products.sorted { $0.price.decimalValue < $1.price.decimalValue }.forEach {
guard let p = Product(rawValue: $0.productIdentifier), p.isDonation, let price = $0.localizedPrice else { guard let p = LocalProduct(rawValue: $0.productIdentifier), p.isDonation, let price = $0.localizedPrice else {
return return
} }
let title = "\($0.localizedTitle) (\(price))" let title = "\($0.localizedTitle) (\(price))"

View File

@ -32,7 +32,7 @@ import Convenience
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self
protocol PurchaseViewControllerDelegate: AnyObject { protocol PurchaseViewControllerDelegate: AnyObject {
func purchaseController(_ purchaseController: PurchaseViewController, didPurchase product: Product?) func purchaseController(_ purchaseController: PurchaseViewController, didPurchase product: LocalProduct?)
} }
class PurchaseViewController: NSViewController { class PurchaseViewController: NSViewController {
@ -52,7 +52,7 @@ class PurchaseViewController: NSViewController {
@IBOutlet private weak var buttonRestore: NSButton! @IBOutlet private weak var buttonRestore: NSButton!
var feature: Product? var feature: LocalProduct?
weak var delegate: PurchaseViewControllerDelegate? weak var delegate: PurchaseViewControllerDelegate?
@ -191,7 +191,7 @@ class PurchaseViewController: NSViewController {
guard let weakSelf = self else { guard let weakSelf = self else {
return return
} }
let product = Product(rawValue: skProduct.productIdentifier) let product = LocalProduct(rawValue: skProduct.productIdentifier)
weakSelf.delegate?.purchaseController(weakSelf, didPurchase: product) weakSelf.delegate?.purchaseController(weakSelf, didPurchase: product)
self?.dismiss(nil) self?.dismiss(nil)

View File

@ -358,11 +358,11 @@ public class AppConstants {
return ProcessInfo.processInfo.environment["FULL_VERSION"] != nil return ProcessInfo.processInfo.environment["FULL_VERSION"] != nil
} }
static let lastFullVersionBuild: (Int, Product) = (2016, .fullVersion_iOS) static let lastFullVersionBuild: (Int, LocalProduct) = (2016, .fullVersion_iOS)
#else #else
static let isBetaFullVersion = false static let isBetaFullVersion = false
static let lastFullVersionBuild: (Int, Product) = (0, .fullVersion_macOS) static let lastFullVersionBuild: (Int, LocalProduct) = (0, .fullVersion_macOS)
#endif #endif
} }
} }

View File

@ -1,5 +1,5 @@
// //
// Product.swift // LocalProduct.swift
// Passepartout // Passepartout
// //
// Created by Davide De Rosa on 10/11/19. // Created by Davide De Rosa on 10/11/19.
@ -26,7 +26,7 @@
import Foundation import Foundation
import StoreKit import StoreKit
public struct Product: RawRepresentable, Equatable, Hashable { public struct LocalProduct: RawRepresentable, Equatable, Hashable {
private static let bundleSubdomain = "ios" private static let bundleSubdomain = "ios"
private static let bundle = "com.algoritmico.\(bundleSubdomain).Passepartout" private static let bundle = "com.algoritmico.\(bundleSubdomain).Passepartout"
@ -39,19 +39,19 @@ public struct Product: RawRepresentable, Equatable, Hashable {
// MARK: Donations // MARK: Donations
public static let tinyDonation = Product(donationDescription: "Tiny") public static let tinyDonation = LocalProduct(donationDescription: "Tiny")
public static let smallDonation = Product(donationDescription: "Small") public static let smallDonation = LocalProduct(donationDescription: "Small")
public static let mediumDonation = Product(donationDescription: "Medium") public static let mediumDonation = LocalProduct(donationDescription: "Medium")
public static let bigDonation = Product(donationDescription: "Big") public static let bigDonation = LocalProduct(donationDescription: "Big")
public static let hugeDonation = Product(donationDescription: "Huge") public static let hugeDonation = LocalProduct(donationDescription: "Huge")
public static let maxiDonation = Product(donationDescription: "Maxi") public static let maxiDonation = LocalProduct(donationDescription: "Maxi")
public static let allDonations: [Product] = [ public static let allDonations: [LocalProduct] = [
.tinyDonation, .tinyDonation,
.smallDonation, .smallDonation,
.mediumDonation, .mediumDonation,
@ -61,24 +61,24 @@ public struct Product: RawRepresentable, Equatable, Hashable {
] ]
private init(donationDescription: String) { private init(donationDescription: String) {
self.init(rawValue: "\(Product.donationsBundle).\(donationDescription)")! self.init(rawValue: "\(LocalProduct.donationsBundle).\(donationDescription)")!
} }
// MARK: Features // MARK: Features
public static let allProviders = Product(featureId: "all_providers") public static let allProviders = LocalProduct(featureId: "all_providers")
public static let trustedNetworks = Product(featureId: "trusted_networks") public static let trustedNetworks = LocalProduct(featureId: "trusted_networks")
public static let siriShortcuts = Product(featureId: "siri") public static let siriShortcuts = LocalProduct(featureId: "siri")
public static let fullVersion_iOS = Product(featureId: "full_version") public static let fullVersion_iOS = LocalProduct(featureId: "full_version")
public static let fullVersion_macOS = Product(featureId: "full_mac_version") public static let fullVersion_macOS = LocalProduct(featureId: "full_mac_version")
public static let fullVersion = Product(featureId: "full_multi_version") public static let fullVersion = LocalProduct(featureId: "full_multi_version")
public static let allFeatures: [Product] = [ public static let allFeatures: [LocalProduct] = [
.allProviders, .allProviders,
.trustedNetworks, .trustedNetworks,
.siriShortcuts, .siriShortcuts,
@ -88,37 +88,37 @@ public struct Product: RawRepresentable, Equatable, Hashable {
] ]
private init(featureId: String) { private init(featureId: String) {
self.init(rawValue: "\(Product.featuresBundle).\(featureId)")! self.init(rawValue: "\(LocalProduct.featuresBundle).\(featureId)")!
} }
// MARK: Providers // MARK: Providers
// public static var allProviders: [Product] { // public static var allProviders: [LocalProduct] {
// return InfrastructureFactory.shared.allMetadata.map { // return InfrastructureFactory.shared.allMetadata.map {
// return Product(providerMetadata: $0) // return LocalProduct(providerMetadata: $0)
// } // }
// } // }
fileprivate init(providerMetadata: Infrastructure.Metadata) { fileprivate init(providerMetadata: Infrastructure.Metadata) {
self.init(rawValue: "\(Product.providersBundle).\(providerMetadata.inApp ?? providerMetadata.name)")! self.init(rawValue: "\(LocalProduct.providersBundle).\(providerMetadata.inApp ?? providerMetadata.name)")!
} }
// MARK: All // MARK: All
public static var all: [Product] { public static var all: [LocalProduct] {
return allDonations + allFeatures// + allProviders return allDonations + allFeatures// + allProviders
} }
public var isDonation: Bool { public var isDonation: Bool {
return rawValue.hasPrefix(Product.donationsBundle) return rawValue.hasPrefix(LocalProduct.donationsBundle)
} }
public var isFeature: Bool { public var isFeature: Bool {
return rawValue.hasPrefix(Product.featuresBundle) return rawValue.hasPrefix(LocalProduct.featuresBundle)
} }
public var isProvider: Bool { public var isProvider: Bool {
return rawValue.hasPrefix(Product.providersBundle) return rawValue.hasPrefix(LocalProduct.providersBundle)
} }
// MARK: RawRepresentable // MARK: RawRepresentable
@ -131,7 +131,7 @@ public struct Product: RawRepresentable, Equatable, Hashable {
// MARK: Equatable // MARK: Equatable
public static func ==(lhs: Product, rhs: Product) -> Bool { public static func ==(lhs: LocalProduct, rhs: LocalProduct) -> Bool {
return lhs.rawValue == rhs.rawValue return lhs.rawValue == rhs.rawValue
} }
@ -143,12 +143,12 @@ public struct Product: RawRepresentable, Equatable, Hashable {
} }
public extension Infrastructure.Metadata { public extension Infrastructure.Metadata {
var product: Product { var product: LocalProduct {
return Product(providerMetadata: self) return LocalProduct(providerMetadata: self)
} }
} }
public extension Product { public extension LocalProduct {
func matchesStoreKitProduct(_ skProduct: SKProduct) -> Bool { func matchesStoreKitProduct(_ skProduct: SKProduct) -> Bool {
return skProduct.productIdentifier == rawValue return skProduct.productIdentifier == rawValue
} }

View File

@ -44,12 +44,12 @@ public class ProductManager: NSObject {
public let isBetaFullVersion: Bool public let isBetaFullVersion: Bool
public let lastFullVersionBuild: (Int, Product) public let lastFullVersionBuild: (Int, LocalProduct)
public init( public init(
locksBetaFeatures: Bool, locksBetaFeatures: Bool,
isBetaFullVersion: Bool, isBetaFullVersion: Bool,
lastFullVersionBuild: (Int, Product) lastFullVersionBuild: (Int, LocalProduct)
) { ) {
self.locksBetaFeatures = locksBetaFeatures self.locksBetaFeatures = locksBetaFeatures
self.isBetaFullVersion = isBetaFullVersion self.isBetaFullVersion = isBetaFullVersion
@ -63,15 +63,15 @@ public class ProductManager: NSObject {
public let cfg: Configuration public let cfg: Configuration
private let inApp: InApp<Product> private let inApp: InApp<LocalProduct>
private var purchasedAppBuild: Int? private var purchasedAppBuild: Int?
private var purchasedFeatures: Set<Product> private var purchasedFeatures: Set<LocalProduct>
private var purchaseDates: [Product: Date] private var purchaseDates: [LocalProduct: Date]
private var cancelledPurchases: Set<Product> private var cancelledPurchases: Set<LocalProduct>
private var refreshRequest: SKReceiptRefreshRequest? private var refreshRequest: SKReceiptRefreshRequest?
@ -108,7 +108,7 @@ public class ProductManager: NSObject {
} }
public func listProducts(completionHandler: (([SKProduct]?, Error?) -> Void)?) { public func listProducts(completionHandler: (([SKProduct]?, Error?) -> Void)?) {
let products = Product.all let products = LocalProduct.all
guard !products.isEmpty else { guard !products.isEmpty else {
completionHandler?(nil, nil) completionHandler?(nil, nil)
return return
@ -122,13 +122,13 @@ public class ProductManager: NSObject {
}) })
} }
public func product(withIdentifier identifier: Product) -> SKProduct? { public func product(withIdentifier identifier: LocalProduct) -> SKProduct? {
return inApp.product(withIdentifier: identifier) return inApp.product(withIdentifier: identifier)
} }
public func featureProducts(including: [Product]) -> [SKProduct] { public func featureProducts(including: [LocalProduct]) -> [SKProduct] {
return inApp.products.filter { return inApp.products.filter {
guard let p = Product(rawValue: $0.productIdentifier) else { guard let p = LocalProduct(rawValue: $0.productIdentifier) else {
return false return false
} }
guard including.contains(p) else { guard including.contains(p) else {
@ -141,9 +141,9 @@ public class ProductManager: NSObject {
} }
} }
public func featureProducts(excluding: [Product]) -> [SKProduct] { public func featureProducts(excluding: [LocalProduct]) -> [SKProduct] {
return inApp.products.filter { return inApp.products.filter {
guard let p = Product(rawValue: $0.productIdentifier) else { guard let p = LocalProduct(rawValue: $0.productIdentifier) else {
return false return false
} }
guard !excluding.contains(p) else { guard !excluding.contains(p) else {
@ -192,7 +192,7 @@ public class ProductManager: NSObject {
return purchasedFeatures.contains(.fullVersion) return purchasedFeatures.contains(.fullVersion)
} }
private func isEligible(forFeature feature: Product) -> Bool { private func isEligible(forFeature feature: LocalProduct) -> Bool {
#if os(iOS) #if os(iOS)
return isFullVersion() || purchasedFeatures.contains(feature) return isFullVersion() || purchasedFeatures.contains(feature)
#else #else
@ -204,7 +204,7 @@ public class ProductManager: NSObject {
return isBeta || !purchasedFeatures.isEmpty return isBeta || !purchasedFeatures.isEmpty
} }
public func verifyEligible(forFeature feature: Product) throws { public func verifyEligible(forFeature feature: LocalProduct) throws {
if isBeta { if isBeta {
if cfg.isBetaFullVersion { if cfg.isBetaFullVersion {
return return
@ -232,15 +232,15 @@ public class ProductManager: NSObject {
} }
} }
public func hasPurchased(_ product: Product) -> Bool { public func hasPurchased(_ product: LocalProduct) -> Bool {
return purchasedFeatures.contains(product) return purchasedFeatures.contains(product)
} }
public func isCancelledPurchase(_ product: Product) -> Bool { public func isCancelledPurchase(_ product: LocalProduct) -> Bool {
return cancelledPurchases.contains(product) return cancelledPurchases.contains(product)
} }
public func purchaseDate(forProduct product: Product) -> Date? { public func purchaseDate(forProduct product: LocalProduct) -> Date? {
return purchaseDates[product] return purchaseDates[product]
} }
@ -273,7 +273,7 @@ public class ProductManager: NSObject {
log.debug("In-app receipts:") log.debug("In-app receipts:")
iapReceipts.forEach { iapReceipts.forEach {
guard let pid = $0.productIdentifier, let product = Product(rawValue: pid) else { guard let pid = $0.productIdentifier, let product = LocalProduct(rawValue: pid) else {
return return
} }
if let cancellationDate = $0.cancellationDate { if let cancellationDate = $0.cancellationDate {