-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StoreKitUnitTests
: compile on iOS 11.0+
#1904
Conversation
The entire target had a deployment target of iOS 14.0 because `SKTestSession` requires it. However, not all tests in that target use `StoreKitConfigTestCase`, and those weren't running before iOS 14.0. To fix this, I've removed the deployment target overrides from all targets (expect for integration tests, those have a higher one for simplicity), and instead defined them only once at the *project level*, so all targets inherit that automatically. `StoreKitConfigTestCase` will skip the test automatically if the iOS is below 14.0, but the other tests will now run on iOS 12 and 13.
IPHONEOS_DEPLOYMENT_TARGET = 11.0; | ||
MACOSX_DEPLOYMENT_TARGET = 10.13; | ||
MTL_ENABLE_DEBUG_INFO = YES; | ||
ONLY_ACTIVE_ARCH = YES; | ||
SDKROOT = iphoneos; | ||
SUPPORTS_MACCATALYST = YES; | ||
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
SWIFT_STRICT_CONCURRENCY = targeted; | ||
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES; | ||
TVOS_DEPLOYMENT_TARGET = 11.0; | ||
VERSIONING_SYSTEM = "apple-generic"; | ||
VERSION_INFO_PREFIX = ""; | ||
WATCHOS_DEPLOYMENT_TARGET = 6.2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ These are now at the project level instead of duplicated in each target.
@@ -69,44 +70,44 @@ extension StoreKitConfigTestCase { | |||
) async { | |||
self.testSession.storefront = new | |||
|
|||
if #available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't necessary, but let's see if tests pass without it.
|
||
import UIKit | ||
|
||
class SceneDelegate: UIResponder, UIWindowSceneDelegate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't needed in the host app (and it's iOS 14.0+ only, so I just removed it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to me
@@ -16,7 +16,9 @@ import Nimble | |||
import StoreKitTest | |||
import XCTest | |||
|
|||
// swiftlint:disable:next type_name | |||
// swiftlint:disable type_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. This will disable the rule for the whole file... Should we reenable at the end of the class? So if any extensions or anything get added later on, this doesn't get applied automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file only has one class (like most test classes) so I think that's unnecessary. Extensions are common to be added at the bottom, but they don't have "type names" so this wouldn't apply.
testSession.clearTransactions() | ||
try super.setUpWithError() | ||
|
||
try AvailabilityChecks.iOS14APIAvailableOrSkipTest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question, can this still be called before iOS 14 with the @available
annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can. The annotation is only for compilation, but XCTest
is not very smart and runs the tests anyway. That's why we have AvailabilityChecks
.
@@ -574,10 +574,8 @@ workflows: | |||
xcode_version: '13.4.1' | |||
- run-test-ios-13: | |||
xcode_version: '13.4.1' | |||
<<: *release-branches-and-main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops I forgot to remove this. Re-added in #1909
**This is an automatic release.** ### Bugfixes * `Purchases.beginRefundRequest`: ensured errors are `PublicError` (#1913) via NachoSoto (@NachoSoto) * `PurchaseTesterSwiftUI`: fixed macOS target (#1915) via NachoSoto (@NachoSoto) ### Other Changes * `SnapshotTesting`: require version 1.9.0 to keep supporting iOS 12/13 tests (#1931) via NachoSoto (@NachoSoto) * Fixed `tvOS` tests (#1928) via NachoSoto (@NachoSoto) * `pre-commit` hook: also verify leftover API keys in `PurchaseTester` (#1914) via NachoSoto (@NachoSoto) * `CircleCI`: changed iOS 12/13 to use Xcode 13 (#1918) via NachoSoto (@NachoSoto) * `PurchaseTesterSwiftUI`: removed unnecessary `UIApplicationDelegate` (#1916) via NachoSoto (@NachoSoto) * `CircleCI`: changed all jobs to use Xcode 14 (#1909) via NachoSoto (@NachoSoto) * `Atomic`: added unit test to verify `value`'s setter (#1905) via NachoSoto (@NachoSoto) * `spm build` CI job: changed to release build (#1903) via NachoSoto (@NachoSoto) * `StoreKitUnitTests`: compile on iOS 11.0+ (#1904) via NachoSoto (@NachoSoto) * `Purchases`: only expose testing data on `DEBUG` (#1902) via NachoSoto (@NachoSoto) * `Integration Tests`: added test to verify re-subscription behavior (#1898) via NachoSoto (@NachoSoto) * `IntegrationTests`: simplified `testExpireSubscription` to fix flaky test (#1899) via NachoSoto (@NachoSoto) * `Integration Tests`: actually verify that entitlement is active (#1880) via NachoSoto (@NachoSoto)
The entire target had a deployment target of iOS 14.0 because
SKTestSession
requires it. However, not all tests in that target useStoreKitConfigTestCase
, and those weren't running before iOS 14.0.To fix this, I've removed the deployment target overrides from all targets (expect for integration tests, those have a higher one for simplicity), and instead defined them only once at the project level, so all targets inherit that automatically.
StoreKitConfigTestCase
will skip the test automatically if the iOS is below 14.0, but the other tests will now run on iOS 12 and 13.