Skip to content

Commit 2fff5b0

Browse files
authored
CI: also run tests on watchOS (#2340)
This is a follow up to #717. In order to be able to reproduce #2338, which seems to be an issue only on `watchOS`, it's important that we now run tests on `watchOS` as well. We probably won't be able to fully replicate that issue since we don't run tests on actual devices, so they'll still run on 64 bits. But this way we might be able to prevent issues that are only reproducible on `watchOS` in the future. ## Changes: - Added CircleCI job - Added lane - Simplified `UnitTestsHostApp` definition using `SwiftUI` - Increased _test only_ `watchOS` deployment target to 7.0 (this was necessary to be able to have a common `@main` for the host app) - Increased _test only_ `tvOS` deployment target to `14.0` (same as above, plus we only run tvOS tests on the latest version anyway. We test backwards compatibility through iOS already) - Fixed test compilation on `watchOS` - Disabled `HTTPClient` tests on `watchOS` (see AliSoftware/OHHTTPStubs#287) - `StoreKitConfigTestCase` is only available from `watchOS 7.0` since that's when `SKTestSession` was introduced - Added `watchOS` support to `UnitTests` target - Added `watchOS` support to `ReceiptParserTests` target - Fixed `isFamilySharable` `watchOS` version checks for version 8.0 - Created new `CI-RevenueCat` Test Plan to only run unit tests and not StoreKit tests on `watchOS`
1 parent 3e221e8 commit 2fff5b0

33 files changed

Lines changed: 177 additions & 75 deletions

.circleci/config.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,24 @@ jobs:
365365
path: fastlane/test_output/xctest
366366
destination: scan-test-output
367367

368+
run-test-watchos:
369+
<<: *base-job
370+
steps:
371+
- checkout
372+
- install-dependencies
373+
- run:
374+
name: Run tests
375+
command: bundle exec fastlane test_watchos
376+
no_output_timeout: 5m
377+
- compress_result_bundle:
378+
directory: fastlane/test_output/xctest/watchos
379+
bundle_name: RevenueCat
380+
- store_test_results:
381+
path: fastlane/test_output
382+
- store_artifacts:
383+
path: fastlane/test_output/xctest
384+
destination: scan-test-output
385+
368386
run-test-ios-14:
369387
<<: *base-job
370388
steps:
@@ -733,6 +751,8 @@ workflows:
733751
xcode_version: '14.2.0'
734752
- run-test-ios-15:
735753
xcode_version: '14.2.0'
754+
- run-test-watchos:
755+
xcode_version: '14.2.0'
736756
- run-test-tvos:
737757
xcode_version: '14.2.0'
738758
- run-test-ios-14:

RevenueCat.xcodeproj/project.pbxproj

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
2DE20B9226409ECF004C597D /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DE20B9126409ECF004C597D /* StoreKit.framework */; };
119119
2DE61A84264190830021CEA0 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DE61A83264190830021CEA0 /* Constants.swift */; };
120120
2DEAC2DD26EFE46E006914ED /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DEAC2DC26EFE46E006914ED /* AppDelegate.swift */; };
121-
2DEAC2E126EFE46E006914ED /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DEAC2E026EFE46E006914ED /* ViewController.swift */; };
122121
2DEAC2E626EFE470006914ED /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2DEAC2E526EFE470006914ED /* Assets.xcassets */; };
123122
2DFF6C56270CA28800ECAFAB /* MockRequestFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 351B517926D44FF000BD2BD7 /* MockRequestFetcher.swift */; };
124123
351B513D26D4491E00BD2BD7 /* MockDeviceCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 351B513C26D4491E00BD2BD7 /* MockDeviceCache.swift */; };
@@ -727,7 +726,6 @@
727726
2DE61A83264190830021CEA0 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
728727
2DEAC2DA26EFE46E006914ED /* UnitTestsHostApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UnitTestsHostApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
729728
2DEAC2DC26EFE46E006914ED /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
730-
2DEAC2E026EFE46E006914ED /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
731729
2DEAC2E526EFE470006914ED /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
732730
2DEAC2EA26EFE470006914ED /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
733731
2DEC0CFB24A2A1B100B0E5BB /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; };
@@ -918,6 +916,7 @@
918916
578D79932936B0810042E434 /* LoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerTests.swift; sourceTree = "<group>"; };
919917
578DAA472948EEAD001700FD /* Clock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clock.swift; sourceTree = "<group>"; };
920918
578DAA492948EF4F001700FD /* TestClock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestClock.swift; sourceTree = "<group>"; };
919+
57910CBD29C393A6006209D5 /* CI-RevenueCat.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = "CI-RevenueCat.xctestplan"; path = "Tests/TestPlans/CI-RevenueCat.xctestplan"; sourceTree = "<group>"; };
921920
579189B628F4747700BF4963 /* EitherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EitherTests.swift; sourceTree = "<group>"; };
922921
579189E828F47E8D00BF4963 /* PurchasesDiagnosticsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchasesDiagnosticsTests.swift; sourceTree = "<group>"; };
923922
579189EA28F47F0F00BF4963 /* MockPurchases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPurchases.swift; sourceTree = "<group>"; };
@@ -1634,7 +1633,6 @@
16341633
isa = PBXGroup;
16351634
children = (
16361635
2DEAC2DC26EFE46E006914ED /* AppDelegate.swift */,
1637-
2DEAC2E026EFE46E006914ED /* ViewController.swift */,
16381636
2DEAC2E526EFE470006914ED /* Assets.xcassets */,
16391637
2DEAC2EA26EFE470006914ED /* Info.plist */,
16401638
);
@@ -2049,6 +2047,7 @@
20492047
570814C128A308050018BAE3 /* BackendIntegrationTests.xctestplan */,
20502048
B3DB3EA5288627D7008EB151 /* CI-AllTests.xctestplan */,
20512049
B3DB3EA828862898008EB151 /* CI-BackendIntegration.xctestplan */,
2050+
57910CBD29C393A6006209D5 /* CI-RevenueCat.xctestplan */,
20522051
570896B427595C8100296F1C /* Coverage.xctestplan */,
20532052
570896B327595C8100296F1C /* RevenueCat.xctestplan */,
20542053
570896B527595C8100296F1C /* UnitTests.xctestplan */,
@@ -3203,7 +3202,6 @@
32033202
isa = PBXSourcesBuildPhase;
32043203
buildActionMask = 2147483647;
32053204
files = (
3206-
2DEAC2E126EFE46E006914ED /* ViewController.swift in Sources */,
32073205
2DEAC2DD26EFE46E006914ED /* AppDelegate.swift in Sources */,
32083206
);
32093207
runOnlyForDeploymentPostprocessing = 0;
@@ -3439,7 +3437,9 @@
34393437
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
34403438
SWIFT_OBJC_BRIDGING_HEADER = "";
34413439
SWIFT_VERSION = 5.0;
3442-
TARGETED_DEVICE_FAMILY = "1,2,3,6";
3440+
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
3441+
TVOS_DEPLOYMENT_TARGET = 14.0;
3442+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
34433443
};
34443444
name = Debug;
34453445
};
@@ -3467,7 +3467,9 @@
34673467
SUPPORTS_MACCATALYST = YES;
34683468
SWIFT_OBJC_BRIDGING_HEADER = "";
34693469
SWIFT_VERSION = 5.0;
3470-
TARGETED_DEVICE_FAMILY = "1,2,3,6";
3470+
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
3471+
TVOS_DEPLOYMENT_TARGET = 14.0;
3472+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
34713473
};
34723474
name = Release;
34733475
};
@@ -3602,6 +3604,8 @@
36023604
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
36033605
SWIFT_VERSION = 5.0;
36043606
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
3607+
TVOS_DEPLOYMENT_TARGET = 14.0;
3608+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
36053609
};
36063610
name = Debug;
36073611
};
@@ -3624,6 +3628,8 @@
36243628
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos watchsimulator watchos appletvsimulator appletvos";
36253629
SWIFT_VERSION = 5.0;
36263630
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
3631+
TVOS_DEPLOYMENT_TARGET = 14.0;
3632+
WATCHOS_DEPLOYMENT_TARGET = 7.0;
36273633
};
36283634
name = Release;
36293635
};
@@ -3784,7 +3790,7 @@
37843790
SUPPORTS_MACCATALYST = YES;
37853791
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
37863792
SWIFT_OBJC_BRIDGING_HEADER = "";
3787-
TARGETED_DEVICE_FAMILY = "1,2,3,6";
3793+
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
37883794
};
37893795
name = Debug;
37903796
};
@@ -3811,7 +3817,7 @@
38113817
SUPPORTED_PLATFORMS = "watchsimulator watchos macosx iphonesimulator iphoneos appletvsimulator appletvos";
38123818
SUPPORTS_MACCATALYST = YES;
38133819
SWIFT_OBJC_BRIDGING_HEADER = "";
3814-
TARGETED_DEVICE_FAMILY = "1,2,3,6";
3820+
TARGETED_DEVICE_FAMILY = "1,2,3,4,6";
38153821
};
38163822
name = Release;
38173823
};

RevenueCat.xcodeproj/xcshareddata/xcschemes/RevenueCat.xcscheme

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
<TestPlanReference
115115
reference = "container:Tests/TestPlans/CI-AllTests.xctestplan">
116116
</TestPlanReference>
117+
<TestPlanReference
118+
reference = "container:Tests/TestPlans/CI-RevenueCat.xctestplan">
119+
</TestPlanReference>
117120
</TestPlans>
118121
<Testables>
119122
<TestableReference

Sources/Purchasing/StoreKitAbstractions/SK1StoreProduct.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal struct SK1StoreProduct: StoreProductType {
5050

5151
var productIdentifier: String { return underlyingSK1Product.productIdentifier }
5252

53-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 8.0, *)
53+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
5454
var isFamilyShareable: Bool { underlyingSK1Product.isFamilyShareable }
5555

5656
var localizedTitle: String { underlyingSK1Product.localizedTitle }

Sources/Purchasing/StoreKitAbstractions/StoreProduct.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public typealias SK2Product = StoreKit.Product
7878

7979
@objc public var productIdentifier: String { self.product.productIdentifier }
8080

81-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 8.0, *)
81+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
8282
@objc public var isFamilyShareable: Bool { self.product.isFamilyShareable }
8383

8484
@available(iOS 12.0, macCatalyst 13.0, tvOS 12.0, macOS 10.14, watchOS 6.2, *)
@@ -151,7 +151,7 @@ internal protocol StoreProductType: Sendable {
151151
///
152152
/// #### Related Articles
153153
/// - https://support.apple.com/en-us/HT201079
154-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 8.0, *)
154+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
155155
var isFamilyShareable: Bool { get }
156156

157157
/// The identifier of the subscription group to which the subscription belongs.

Tests/APITesters/ObjCAPITester/ObjCAPITester/RCPurchasesAPI.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ + (void)checkAPI {
182182

183183
}];
184184

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

193-
#if TARGET_OS_IPHONE && !TARGET_OS_TV
193+
#if TARGET_OS_IPHONE && !TARGET_OS_TV && !TARGET_OS_WATCH
194194
[p presentCodeRedemptionSheet];
195195
#endif
196196
}

Tests/APITesters/SwiftAPITester/SwiftAPITester/AttributionAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func checkAttributionAPI() {
7272

7373
attribution.collectDeviceIdentifiers()
7474

75-
#if !os(tvOS)
75+
#if !os(tvOS) && !os(watchOS)
7676
attribution.enableAdServicesAttributionTokenCollection()
7777
#endif
7878
}

Tests/StoreKitUnitTests/LocalReceiptParserStoreKitTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Nimble
1717
import StoreKit
1818
import XCTest
1919

20-
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
20+
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
2121
class LocalReceiptParserStoreKitTests: StoreKitConfigTestCase {
2222

2323
private let operationDispatcher: OperationDispatcher = .default

Tests/StoreKitUnitTests/OfferingsManagerStoreKitTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import XCTest
1616

1717
@testable import RevenueCat
1818

19-
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
19+
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
2020
class OfferingsManagerStoreKitTests: StoreKitConfigTestCase {
2121

2222
var mockDeviceCache: MockDeviceCache!
@@ -47,7 +47,7 @@ class OfferingsManagerStoreKitTests: StoreKitConfigTestCase {
4747

4848
}
4949

50-
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
50+
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
5151
extension OfferingsManagerStoreKitTests {
5252

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

8383
}
8484

85-
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
85+
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
8686
private extension OfferingsManagerStoreKitTests {
8787

8888
enum MockData {

Tests/StoreKitUnitTests/PriceFormatterProviderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import XCTest
1717

1818
@testable import RevenueCat
1919

20-
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 6.2, *)
20+
@available(iOS 14.0, tvOS 14.0, macOS 11.0, watchOS 7.0, *)
2121
class PriceFormatterProviderTests: StoreKitConfigTestCase {
2222

2323
private var priceFormatterProvider: PriceFormatterProvider!

0 commit comments

Comments
 (0)