Skip to content
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

Add uiPreviewMode to DangerousSettings #4714

Merged
merged 4 commits into from
Jan 28, 2025
Merged

Conversation

ajpallares
Copy link
Member

@ajpallares ajpallares commented Jan 27, 2025

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

We need a way to activate the UI Preview mode in the SDK to enable the Paywall Previews functionality in the RC app without actually adding any new public APIs to the SDK

Description

This PR adds a new property to DangerousSettings: uiPreviewMode.

  • This new public API is opt-in only, thanks to the @_spi attribute.
  • The UI Preview Mode of the SDK will limit all the functionality of the SDK to only enable implementing the Paywall Previews functionality (and similar) in the RevenueCat app, so that developers can properly test their paywalls on their own devices.

@ajpallares ajpallares requested a review from a team January 27, 2025 15:40
@ajpallares ajpallares mentioned this pull request Jan 27, 2025
2 tasks
@ajpallares ajpallares marked this pull request as ready for review January 27, 2025 15:56
@ajpallares
Copy link
Member Author

I have added the uiPreviewMode as a DangerousSettings:

  1. This should make it double clear that it's not for public use (DangerousSettings + @_spi attribute). In fact, the @_spi attribute does prevent the use of this API for regular imports of the SDK.
  2. In a future major release, we can move everything that currently lives under DangerousSettings, to use the @_spi attribute. So we can use this uiPreviewMode as a first step towards that goal.

Of course, I'm open to suggestions about adding the uiPreviewMode to a better-fitting place.

@ajpallares ajpallares requested a review from a team January 27, 2025 16:03
@aboedo
Copy link
Member

aboedo commented Jan 27, 2025

I triggered a re-run of the iOS 18 tests since the failures seemed unrelated

Copy link
Member

@aboedo aboedo left a comment

Choose a reason for hiding this comment

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

awesome!

Comment on lines +61 to +66
/**
* if `true`, the SDK will return a set of mock products instead of the
* products obtained from StoreKit. This is useful for testing or preview purposes.
*/
@_spi(Internal) public let uiPreviewMode: Bool

Copy link
Member

Choose a reason for hiding this comment

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

maybe we can add the API tests to go along with it in this same PR? Those serve to also showcase the usage

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in f406e82

Sources/Misc/DangerousSettings.swift Show resolved Hide resolved
Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

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

@_spi all the things! 🙌

I don't have a strong opinion on whether it should be in DangerousSettings or not. I'd also be okay to just move this to the regular Configuration. However, since it's internal we can always change this later.

Sources/Misc/DangerousSettings.swift Outdated Show resolved Hide resolved
@ajpallares ajpallares requested a review from aboedo January 28, 2025 09:10
@ajpallares
Copy link
Member Author

@RCGitBot please test

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

LGTM! Nice knowing this 💪

@ajpallares ajpallares merged commit b94b47e into main Jan 28, 2025
38 checks passed
@ajpallares ajpallares deleted the pallares/uiPreviewMode branch January 28, 2025 15:48
@ajpallares ajpallares mentioned this pull request Jan 28, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants