Disable StoreKit auto access in debug simulators#54
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a564505466
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard !StoreKitDevelopmentMode.shouldSkipStoreKitAccess else { | ||
| purchaseError = String( | ||
| localized: "Purchases are disabled in local simulator builds. Set HEALTHMD_ENABLE_STOREKIT_IN_SIMULATOR=1 to test StoreKit.", | ||
| comment: "Local simulator StoreKit disabled error" | ||
| ) | ||
| return | ||
| } |
There was a problem hiding this comment.
Preserve purchase analytics path in simulator unit tests
The new simulator guard returns from purchase() before trackPurchaseStarted, which changes behavior for all DEBUG simulator runs, including non-UI XCTest runs that use the injected PurchaseManager initializer. In that environment shouldSkipStoreKitAccess is true by default, so existing logic tests (for example PurchaseManagerTests.testPurchaseUnavailableTracksStartedAndFailedOutcome) can no longer exercise the purchase analytics/error path and will fail or become environment-dependent. This guard should be scoped to app-runtime StoreKit interactions (or bypassed under XCTest) so unit-test business logic remains deterministic.
Useful? React with 👍 / 👎.
Summary
How to test StoreKit locally
Set
HEALTHMD_ENABLE_STOREKIT_IN_SIMULATOR=1in the scheme environment, or setdebugEnableStoreKitInSimulatorin UserDefaults, to opt back into StoreKit on simulator.Tests
xcodebuild test -project HealthMd.xcodeproj -scheme HealthMd-Tests-iOS -destination 'platform=iOS Simulator,name=iPhone 17 Pro' -only-testing:HealthMdTests/StoreKitDevelopmentModeTests CODE_SIGNING_ALLOWED=NO