Skip to content

Commit

Permalink
TestStoreProduct: made available on release builds
Browse files Browse the repository at this point in the history
See #2711. This is needed for #2855. In order to be able to create test products for the paywall loading screen, we need to be able to do this in release builds as well.
Another benefit of exposing `TestStoreProduct` in release builds is that it's also usable for pre-built versions of the SDK (like Carthage).
  • Loading branch information
NachoSoto committed Jul 23, 2023
1 parent b4a71a9 commit 38e88c5
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 74 deletions.
4 changes: 0 additions & 4 deletions Sources/Purchasing/StoreKitAbstractions/StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,7 @@ extension StoreProduct {
}

var isTestProduct: Bool {
#if DEBUG
return self.product is TestStoreProduct
#else
return false
#endif
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import Foundation

#if DEBUG

/// A type that contains the necessary data to create a ``StoreProduct``.
/// This can be used to create mock data for tests or SwiftUI previews.
///
Expand Down Expand Up @@ -120,29 +118,3 @@ extension TestStoreProduct {
}

}

#else

// swiftlint:disable missing_docs

@available(
iOS,
obsoleted: 1,
message: "This API is only available for debug builds. Use #if DEBUG to conditionally compile it."
)
public struct TestStoreProduct {

public init(
localizedTitle: String,
price: Decimal,
localizedPriceString: String,
productIdentifier: String,
productType: StoreProduct.ProductType,
localizedDescription: String,
subscriptionGroupIdentifier: String? = nil,
subscriptionPeriod: SubscriptionPeriod? = nil
) {}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import Foundation

#if DEBUG

/// A type that contains the necessary data to create a ``StoreProduct``.
public struct TestStoreProductDiscount {

Expand Down Expand Up @@ -70,29 +68,3 @@ extension TestStoreProductDiscount {
}

}

#else

@available(
iOS,
obsoleted: 1,
message: "This API is only available for debug builds. Use #if DEBUG to conditionally compile it."
)
// swiftlint:disable missing_docs
public struct TestStoreProductDiscount {

public init(
identifier: String,
price: Decimal,
localizedPriceString: String,
paymentMode: StoreProductDiscount.PaymentMode,
subscriptionPeriod: SubscriptionPeriod,
numberOfPeriods: Int,
type: StoreProductDiscount.DiscountType
) {}

}

// swiftlint:enable missing_docs

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import RevenueCat

#if DEBUG

// swiftlint:disable syntactic_sugar

private var testProduct: TestStoreProduct!
Expand Down Expand Up @@ -67,5 +65,3 @@ private func checkStoreProductCreation(discount: TestStoreProductDiscount) {
discounts: [discount]
)
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import RevenueCat

#if DEBUG

var testProductDiscount: TestStoreProductDiscount!

func checkTestStoreProductDiscountAPI() {
Expand Down Expand Up @@ -52,5 +50,3 @@ private func checkCreateStoreProduct() {
type: .promotional
)
}

#endif
2 changes: 0 additions & 2 deletions Tests/APITesters/SwiftAPITester/SwiftAPITester/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ func main() -> Int {
checkStoreProductAPI()
checkStoreProductDiscountAPI()

#if DEBUG
checkTestStoreProductAPI()
checkTestStoreProductDiscountAPI()
#endif

checkPaymentModeEnum()

Expand Down
4 changes: 0 additions & 4 deletions Tests/StoreKitUnitTests/StoreProductTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ class StoreProductTests: StoreKitConfigTestCase {
expect(nonSubscription.productCategory) == .nonSubscription
}

#if DEBUG

func testTestProduct() {
let title = "Product"
let price: Decimal = 3.99
Expand Down Expand Up @@ -388,8 +386,6 @@ class StoreProductTests: StoreKitConfigTestCase {
expect(storeProduct.isFamilyShareable) == isFamilyShareable
}

#endif

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
Expand Down

0 comments on commit 38e88c5

Please sign in to comment.