Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,24 @@ jobs:
path: fastlane/test_output/xctest
destination: scan-test-output

run-test-watchos:
<<: *base-job
steps:
- checkout
- install-dependencies
- run:
name: Run tests
command: bundle exec fastlane test_watchos
no_output_timeout: 5m
- compress_result_bundle:
directory: fastlane/test_output/xctest/watchos
bundle_name: RevenueCat
- store_test_results:
path: fastlane/test_output
- store_artifacts:
path: fastlane/test_output/xctest
destination: scan-test-output

run-test-ios-14:
<<: *base-job
steps:
Expand Down Expand Up @@ -733,6 +751,8 @@ workflows:
xcode_version: '14.2.0'
- run-test-ios-15:
xcode_version: '14.2.0'
- run-test-watchos:
xcode_version: '14.2.0'
- run-test-tvos:
xcode_version: '14.2.0'
- run-test-ios-14:
Expand Down
22 changes: 14 additions & 8 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
2DE20B9226409ECF004C597D /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DE20B9126409ECF004C597D /* StoreKit.framework */; };
2DE61A84264190830021CEA0 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DE61A83264190830021CEA0 /* Constants.swift */; };
2DEAC2DD26EFE46E006914ED /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DEAC2DC26EFE46E006914ED /* AppDelegate.swift */; };
2DEAC2E126EFE46E006914ED /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DEAC2E026EFE46E006914ED /* ViewController.swift */; };
2DEAC2E626EFE470006914ED /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2DEAC2E526EFE470006914ED /* Assets.xcassets */; };
2DFF6C56270CA28800ECAFAB /* MockRequestFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 351B517926D44FF000BD2BD7 /* MockRequestFetcher.swift */; };
351B513D26D4491E00BD2BD7 /* MockDeviceCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 351B513C26D4491E00BD2BD7 /* MockDeviceCache.swift */; };
Expand Down Expand Up @@ -727,7 +726,6 @@
2DE61A83264190830021CEA0 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
2DEAC2DA26EFE46E006914ED /* UnitTestsHostApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UnitTestsHostApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
2DEAC2DC26EFE46E006914ED /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2DEAC2E026EFE46E006914ED /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
2DEAC2E526EFE470006914ED /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2DEAC2EA26EFE470006914ED /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2DEC0CFB24A2A1B100B0E5BB /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -918,6 +916,7 @@
578D79932936B0810042E434 /* LoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerTests.swift; sourceTree = "<group>"; };
578DAA472948EEAD001700FD /* Clock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clock.swift; sourceTree = "<group>"; };
578DAA492948EF4F001700FD /* TestClock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestClock.swift; sourceTree = "<group>"; };
57910CBD29C393A6006209D5 /* CI-RevenueCat.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = "CI-RevenueCat.xctestplan"; path = "Tests/TestPlans/CI-RevenueCat.xctestplan"; sourceTree = "<group>"; };
579189B628F4747700BF4963 /* EitherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EitherTests.swift; sourceTree = "<group>"; };
579189E828F47E8D00BF4963 /* PurchasesDiagnosticsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchasesDiagnosticsTests.swift; sourceTree = "<group>"; };
579189EA28F47F0F00BF4963 /* MockPurchases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPurchases.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1634,7 +1633,6 @@
isa = PBXGroup;
children = (
2DEAC2DC26EFE46E006914ED /* AppDelegate.swift */,
2DEAC2E026EFE46E006914ED /* ViewController.swift */,
2DEAC2E526EFE470006914ED /* Assets.xcassets */,
2DEAC2EA26EFE470006914ED /* Info.plist */,
);
Expand Down Expand Up @@ -2049,6 +2047,7 @@
570814C128A308050018BAE3 /* BackendIntegrationTests.xctestplan */,
B3DB3EA5288627D7008EB151 /* CI-AllTests.xctestplan */,
B3DB3EA828862898008EB151 /* CI-BackendIntegration.xctestplan */,
57910CBD29C393A6006209D5 /* CI-RevenueCat.xctestplan */,
570896B427595C8100296F1C /* Coverage.xctestplan */,
570896B327595C8100296F1C /* RevenueCat.xctestplan */,
570896B527595C8100296F1C /* UnitTests.xctestplan */,
Expand Down Expand Up @@ -3203,7 +3202,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2DEAC2E126EFE46E006914ED /* ViewController.swift in Sources */,
2DEAC2DD26EFE46E006914ED /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3439,7 +3437,9 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
TVOS_DEPLOYMENT_TARGET = 14.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
};
name = Debug;
};
Expand Down Expand Up @@ -3467,7 +3467,9 @@
SUPPORTS_MACCATALYST = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
TVOS_DEPLOYMENT_TARGET = 14.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
};
name = Release;
};
Expand Down Expand Up @@ -3602,6 +3604,8 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
TVOS_DEPLOYMENT_TARGET = 14.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
};
name = Debug;
};
Expand All @@ -3624,6 +3628,8 @@
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos watchsimulator watchos appletvsimulator appletvos";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
TVOS_DEPLOYMENT_TARGET = 14.0;
WATCHOS_DEPLOYMENT_TARGET = 7.0;
};
name = Release;
};
Expand Down Expand Up @@ -3784,7 +3790,7 @@
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OBJC_BRIDGING_HEADER = "";
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
};
name = Debug;
};
Expand All @@ -3811,7 +3817,7 @@
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos appletvsimulator appletvos";
SUPPORTS_MACCATALYST = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
TARGETED_DEVICE_FAMILY = "1,2,3,6";
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
<TestPlanReference
reference = "container:Tests/TestPlans/CI-AllTests.xctestplan">
</TestPlanReference>
<TestPlanReference
reference = "container:Tests/TestPlans/CI-RevenueCat.xctestplan">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ + (void)checkAPI {

}];

#if (TARGET_OS_IPHONE || TARGET_OS_MACCATALYST) && !TARGET_OS_TV
#if (TARGET_OS_IPHONE || TARGET_OS_MACCATALYST) && !TARGET_OS_TV && !TARGET_OS_WATCH
[p beginRefundRequestForProduct:@"1234" completion:^(RCRefundRequestStatus s, NSError * _Nullable e) { }];
[p beginRefundRequestForEntitlement:@"" completion:^(RCRefundRequestStatus s, NSError * _Nullable e) { }];
[p beginRefundRequestForActiveEntitlementWithCompletion:^(RCRefundRequestStatus s, NSError * _Nullable e) { }];
[p showPriceConsentIfNeeded];
BOOL consent __unused = [p.delegate shouldShowPriceConsent];
#endif

#if TARGET_OS_IPHONE && !TARGET_OS_TV
#if TARGET_OS_IPHONE && !TARGET_OS_TV && !TARGET_OS_WATCH
[p presentCodeRedemptionSheet];
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func checkAttributionAPI() {

attribution.collectDeviceIdentifiers()

#if !os(tvOS)
#if !os(tvOS) && !os(watchOS)
attribution.enableAdServicesAttributionTokenCollection()
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Nimble
import StoreKit
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh, SKTestSession is watchOS 7+, I'm surprised this even worked before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We never compiled this on watchOS.

class LocalReceiptParserStoreKitTests: StoreKitConfigTestCase {

private let operationDispatcher: OperationDispatcher = .default
Expand Down
6 changes: 3 additions & 3 deletions Tests/StoreKitUnitTests/OfferingsManagerStoreKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import XCTest

@testable import RevenueCat

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class OfferingsManagerStoreKitTests: StoreKitConfigTestCase {

var mockDeviceCache: MockDeviceCache!
Expand Down Expand Up @@ -47,7 +47,7 @@ class OfferingsManagerStoreKitTests: StoreKitConfigTestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
extension OfferingsManagerStoreKitTests {

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
Expand Down Expand Up @@ -82,7 +82,7 @@ extension OfferingsManagerStoreKitTests {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
private extension OfferingsManagerStoreKitTests {

enum MockData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import XCTest

@testable import RevenueCat

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class PriceFormatterProviderTests: StoreKitConfigTestCase {

private var priceFormatterProvider: PriceFormatterProvider!
Expand Down
4 changes: 2 additions & 2 deletions Tests/StoreKitUnitTests/ProductsManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Nimble
import StoreKitTest
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class ProductsManagerTests: StoreKitConfigTestCase {

func testFetchProductsWithIdentifiersSK1() throws {
Expand All @@ -36,7 +36,7 @@ class ProductsManagerTests: StoreKitConfigTestCase {
}

func testFetchProductsWithIdentifiersSK2() throws {
guard #available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 7.0, *) else {
guard #available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *) else {
throw XCTSkip("Required API is not available for this test.")
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/StoreKitUnitTests/PurchasesOrchestratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Nimble
import StoreKit
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class PurchasesOrchestratorTests: StoreKitConfigTestCase {

private var productsManager: MockProductsManager!
Expand Down Expand Up @@ -980,7 +980,7 @@ class PurchasesOrchestratorTests: StoreKitConfigTestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
private extension PurchasesOrchestratorTests {

@MainActor
Expand Down
6 changes: 3 additions & 3 deletions Tests/StoreKitUnitTests/StoreKitConfigTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Nimble
import StoreKitTest
import XCTest

/// Available from iOS 14.0 because that's when `SKTestSession was introduced`.
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
/// Available from iOS 14.0 because that's when `SKTestSession` was introduced.
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class StoreKitConfigTestCase: TestCase {

static var requestTimeout: TimeInterval = 60
Expand Down Expand Up @@ -86,7 +86,7 @@ class StoreKitConfigTestCase: TestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
private extension StoreKitConfigTestCase {

func waitForStoreKitTestIfNeeded() {
Expand Down
17 changes: 10 additions & 7 deletions Tests/StoreKitUnitTests/StoreProductTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Nimble
import StoreKitTest
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class StoreProductTests: StoreKitConfigTestCase {

private var sk1Fetcher: ProductsFetcherSK1!
Expand Down Expand Up @@ -107,14 +107,17 @@ class StoreProductTests: StoreKitConfigTestCase {
expect(storeProduct.price.description) == "4.99"
expect(storeProduct.priceDecimalNumber).to(beCloseTo(4.99))
expect(storeProduct.localizedPriceString) == "$4.99"
expect(storeProduct.isFamilyShareable) == true
expect(storeProduct.localizedTitle) == "Monthly Free Trial"
// open the StoreKit Config file as source code to see the expected value
expect(storeProduct.subscriptionGroupIdentifier) == "7096FF06"

expect(storeProduct.subscriptionPeriod?.unit) == .month
expect(storeProduct.subscriptionPeriod?.value) == 1

if #available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 8.0, *) {
expect(storeProduct.isFamilyShareable) == true
}

let intro = try XCTUnwrap(storeProduct.introductoryDiscount)

expect(intro.price) == 0.0
Expand Down Expand Up @@ -343,7 +346,7 @@ class StoreProductTests: StoreKitConfigTestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
private extension StoreProductTests {

func expectEqualProducts(_ productA: StoreProductType, _ productB: StoreProductType) {
Expand All @@ -354,13 +357,13 @@ private extension StoreProductTests {
expect(productA.price) == productB.price
expect(productA.localizedPriceString) == productB.localizedPriceString
expect(productA.productIdentifier) == productB.productIdentifier
expect(productA.isFamilyShareable) == productB.isFamilyShareable
expect(productA.localizedTitle) == productB.localizedTitle

expect(productA.isFamilyShareable) == productB.isFamilyShareable

expect(productA.discounts) == productB.discounts

if #available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 8.0, *) {
expect(productA.isFamilyShareable) == productB.isFamilyShareable
}

if productA.subscriptionPeriod == nil {
expect(productB.subscriptionPeriod).to(beNil())
} else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StoreKitUnitTests/StoreTransactionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Nimble
import StoreKitTest
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class StoreTransactionTests: StoreKitConfigTestCase {

func testSK1DetailsWrapCorrectly() async throws {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StoreKitUnitTests/StorefrontTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Nimble
import StoreKit
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class StorefrontTests: StoreKitConfigTestCase {

@MainActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extension StoreKitConfigTestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
extension StoreKitConfigTestCase {

/// Updates `SKTestSession.storefront` and waits for `Storefront.current` to reflect the change
Expand All @@ -80,15 +80,15 @@ extension StoreKitConfigTestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
extension StoreKitConfigTestCase {

static let productID = "com.revenuecat.monthly_4.99.1_week_intro"
static let lifetimeProductID = "lifetime"

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
fileprivate extension StoreKitConfigTestCase {

enum Error: Swift.Error {
Expand All @@ -100,7 +100,7 @@ fileprivate extension StoreKitConfigTestCase {

}

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
extension ProductsFetcherSK1 {

func product(withIdentifier identifier: String) async throws -> StoreProduct {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StoreKitUnitTests/TransactionsManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Nimble
@testable import RevenueCat
import XCTest

@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
class TransactionsManagerTests: StoreKitConfigTestCase {

private var mockReceiptParser: MockReceiptParser!
Expand Down
Loading