Skip to content

Disable StoreKit auto access in debug simulators#54

Open
CodyBontecou wants to merge 1 commit into
mainfrom
fix/local-simulator-storekit-popup
Open

Disable StoreKit auto access in debug simulators#54
CodyBontecou wants to merge 1 commit into
mainfrom
fix/local-simulator-storekit-popup

Conversation

@CodyBontecou

Copy link
Copy Markdown
Owner

Summary

  • Add a local StoreKit development mode guard that defaults DEBUG simulator builds away from StoreKit APIs.
  • Gate automatic product loading, entitlement refreshes, transaction listeners, silent receipt verification, restore, purchase, and receipt diagnostics behind that guard.
  • Add tests for simulator defaults, explicit opt-in, UI test skipping, and truthy environment parsing.

How to test StoreKit locally

Set HEALTHMD_ENABLE_STOREKIT_IN_SIMULATOR=1 in the scheme environment, or set debugEnableStoreKitInSimulator in 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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +306 to +312
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
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant