Skip to content

[Conditional Configurability][4] Validate unsupported conditions in toPresentedOverrides#6288

Merged
facumenzella merged 11 commits into
facundo/cocofrom
facundo/coco-4
Feb 23, 2026
Merged

[Conditional Configurability][4] Validate unsupported conditions in toPresentedOverrides#6288
facumenzella merged 11 commits into
facundo/cocofrom
facundo/coco-4

Conversation

@facumenzella

@facumenzella facumenzella commented Feb 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Add unsupportedCondition case to PaywallError for triggering fallback
  • Validate conditions in toPresentedOverrides - throw if any unsupported condition is detected
  • Add logging string paywall_contains_unsupported_condition
  • Add comprehensive tests for unsupported condition detection in various scenarios
  • Add VideoComponentViewModel.forBackground() non-throwing factory for video backgrounds

This ensures that paywalls containing conditions not recognized by the current SDK version safely fall back to the default paywall.

Android equivalent: RevenueCat/purchases-android#3113
https://github.com/RevenueCat/sdk-specs/tree/main/openspec/changes/add-conditional-configurability-v0

Test plan

  • Added ToPresentedOverridesTests with tests for:
    • Single unsupported condition throws error
    • Unsupported condition among others throws error
    • Multiple overrides with one containing unsupported throws error
    • All supported conditions succeeds
    • Empty overrides succeeds
    • New condition types (selectedPackageCondition, variableCondition, introOfferCondition) succeed

🤖 Generated with Claude Code


Note

Medium Risk
Changes paywall rendering/view-model construction to throw and short-circuit when encountering unknown override conditions; mistakes could increase fallback rates or surface new errors in paywall loading paths.

Overview
Adds an explicit PaywallError.unsupportedCondition path and a new log string to force a safe fallback when a paywall (or any nested component override) contains condition types this SDK can’t evaluate.

toPresentedOverrides now validates override conditions up front and throws on .unsupported, propagating through component view model initializers (now throws) and causing PaywallsV2View.createPaywallState to detect/abort early with a warning + fallback. Also adds VideoComponentViewModel.forBackground() to keep background video creation non-throwing, and updates API tests to use numeric/bool custom variable values plus new unit tests covering unsupported-condition detection.

Written by Cursor Bugbot for commit 9f146e3. This will update automatically on new commits. Configure here.

@emerge-tools

emerge-tools Bot commented Feb 18, 2026

Copy link
Copy Markdown

3 builds increased size, 1 build had no size change

Name Version Download Change Install Change Approval
RevenueCat
com.revenuecat.PaywallsTester
1.0 (1) 17.5 MB ⬆️ 42.2 kB (0.24%) 62.5 MB ⬆️ 128.2 kB (0.21%) N/A
BinarySizeTest
com.revenuecat.binary-size-test.local-source
1.0 (1) 3.8 MB ⬆️ 21.1 kB (0.56%) 11.4 MB ⬆️ 65.9 kB (0.59%) ⏳ Needs approval
BinarySizeTest
com.revenuecat.binary-size-test.cocoapods
1.0 (1) 5.7 MB ⬆️ 27.0 kB (0.47%) 25.3 MB ⬆️ 115.8 kB (0.46%) ⏳ Needs approval
BinarySizeTest
com.revenuecat.binary-size-test.spm
1.0 (1) 3.3 MB ⬆️ 28 B 10.1 MB - N/A

RevenueCat 1.0 (1)
com.revenuecat.PaywallsTester

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 128.2 kB (0.21%)
Total download size change: ⬆️ 42.2 kB (0.24%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 38.6 kB
RevenueCatUI.VideoComponentViewModel.VideoComponentViewModel ⬆️ 9.8 kB
Code Signature ⬆️ 3.2 kB
DYLD.Exports ⬆️ 2.9 kB
📝 RevenueCat.PaywallComponent.ExtendedCondition.Swift Metadata ⬆️ 728 B
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.local-source

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 65.9 kB (0.59%)
Total download size change: ⬆️ 21.1 kB (0.56%)

Largest size changes

Item Install Size Change
RevenueCatUI.VideoComponentViewModel.styles(state,condition,isEli... ⬆️ 4.3 kB
RevenueCat.PaywallComponent.ComponentOverride.hash(into) ⬆️ 4.2 kB
RevenueCat.PaywallComponent.CountdownComponent.CountdownComponent ⬆️ 3.2 kB
RevenueCatUI.IconComponentViewModel.styles(state,condition,isElig... ⬆️ 3.1 kB
RevenueCat.PaywallComponent.VideoComponent.VideoComponent ⬆️ 3.1 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.cocoapods

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 115.8 kB (0.46%)
Total download size change: ⬆️ 27.0 kB (0.47%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 15.8 kB
DYLD.String Table ⬆️ 13.0 kB
RevenueCatUI.Template2View.iconImage ⬆️ 8.0 kB
RevenueCat.PaywallComponent.ComponentOverride.hash(into) ⬆️ 4.2 kB
RevenueCat.PaywallComponent.VideoComponent.VideoComponent ⬆️ 3.1 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.spm

No changes to report


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

@facumenzella facumenzella changed the title Validate unsupported conditions in toPresentedOverrides [Conditional Configurability][4] Validate unsupported conditions in toPresentedOverrides Feb 18, 2026
@facumenzella facumenzella force-pushed the facundo/coco-4 branch 2 times, most recently from 09fa54d to d807f35 Compare February 20, 2026 11:54
facumenzella and others added 3 commits February 20, 2026 13:17
Add comprehensive tests for the condition evaluation logic:
- Selected package condition tests (in/not in operators)
- Variable condition tests (string, int, not found)
- Extended intro offer condition tests (equals/not equals)
- Multiple conditions (AND logic) tests
- Unsupported condition tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add promo offer condition tests with operators
- Add variable boolean, double, and type mismatch tests
- Add intro offer negative test case
- Fix @available annotations for ConditionContext and related methods
- Fix matchesValue to use CustomVariableValue getters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add isString, isNumber, isBool type checking methods to CustomVariableValue
- Update matchesValue to perform type-strict comparison (string != int, etc.)
- Remove accidentally committed PR_6285_review.md and package-lock.json
- Revert unrelated Package.resolved changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `PaywallError.unsupportedCondition` case for future fallback support
- Add `containsUnsupportedConditions()` method to detect unsupported conditions
- Add logging string for unsupported condition warning
- Add comprehensive tests for unsupported condition detection

Note: The actual fallback mechanism (throwing and catching at paywall level)
will be implemented in a follow-up PR to avoid cascading changes to all
component ViewModels.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
facumenzella and others added 2 commits February 20, 2026 13:17
Allow developers to pass numeric and boolean custom variables to paywalls,
enabling condition evaluation based on these types.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The CustomVariableValue factory methods .number() and .bool() are now
public. Update the API tester to use these methods directly instead of
using .string() for all values.

Existing test coverage in VariableHandlerV2Tests.swift already covers
these factory methods comprehensively.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Base automatically changed from facundo/coco-3 to facundo/coco February 20, 2026 12:18
This matches Android's approach where toPresentedOverrides checks for
unsupported conditions and throws PaywallError.unsupportedCondition,
triggering fallback to the default paywall.

Changes:
- toPresentedOverrides now throws when unsupported conditions are found
- Updated all view model initializers to be throwing
- Updated ViewModelFactory to use try when instantiating view models
- Used try? with fallback for video backgrounds in SwiftUI contexts
- Updated preview code with try!/force_try

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
facumenzella and others added 2 commits February 20, 2026 14:45
Add test coverage verifying that toPresentedOverrides throws
PaywallError.unsupportedCondition when any override contains an
unsupported condition type.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…6319)

* Integrate unsupported condition validation into toPresentedOverrides

This matches Android's approach where toPresentedOverrides checks for
unsupported conditions and throws PaywallError.unsupportedCondition,
triggering fallback to the default paywall.

Changes:
- toPresentedOverrides now throws when unsupported conditions are found
- Updated all view model initializers to be throwing
- Updated ViewModelFactory to use try when instantiating view models
- Used try? with fallback for video backgrounds in SwiftUI contexts
- Updated preview code with try!/force_try

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* suggestions

^ Conflicts:
^	RevenueCatUI/Data/CustomPaywallVariables.swift
^	RevenueCatUI/Templates/V2/ViewModelHelpers/PresentedPartials.swift

* internal bool and number

* fallback paywall

* Fix compilation error and SwiftLint violations

- Fix call to renamed method: containsUnsupportedConditions -> hasUnsupportedCondition
- Rename variable 'c' to 'component' to satisfy identifier_name rule
- Add swiftlint:disable for cyclomatic_complexity

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove accidental .package.resolved file

* Remove extra blank lines

---------

Co-authored-by: Facundo Menzella <facumenzella@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
) -> Bool {
guard let actualValue = customVariables[variable] else {
// Variable not found - condition doesn't match
return false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing variables match notEquals conditions

Medium Severity

evaluateVariableCondition now treats an absent customVariables[variable] as a match when the operator is .notEquals. This can cause overrides guarded by “variable != X” to apply even when the variable is not provided at all, which is a behavior change from always not matching when missing.

Fix in Cursor Fix in Web

@facumenzella

Copy link
Copy Markdown
Member Author

Re: Cursor's comment about missing variables matching notEquals conditions:

This behavior is intentional and matches Android. See the equivalent implementation in purchases-android PR #3117:

val variableValue = customVariables[variable] ?: return operator == ComponentOverride.EqualityOperator.NOT_EQUALS

Both platforms treat missing variables as:

  • variable == "foo"false (missing is not equal to anything)
  • variable != "foo"true (missing is indeed not equal to "foo")

)
) else {
// Fallback to image if video fails (unlikely for backgrounds)
return .image(image, fitMode, colorScheme?.asDisplayable(uiConfigProvider: uiConfigProvider))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we doing this differently for videos?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch! Fixed by adding a non-throwing factory method for video backgrounds:

// VideoComponentViewModel.swift
static func forBackground(...) -> VideoComponentViewModel

Now DisplayableColor.swift uses this directly without try?:

let viewModel = VideoComponentViewModel.forBackground(...)

This is consistent with other components - early validation catches unsupported conditions, and video backgrounds use a dedicated non-throwing path since they have no overrides.

@facumenzella

Copy link
Copy Markdown
Member Author

Re: vegaro's comment about video backgrounds being handled differently:

Good catch. The try? with fallback was inconsistent with how other components handle errors.

Fixed by adding a non-throwing factory method for video backgrounds:

// VideoComponentViewModel.swift
static func forBackground(...) -> VideoComponentViewModel {
    // Non-throwing because video backgrounds don't have overrides
}

Now DisplayableColor.swift uses this directly:

let viewModel = VideoComponentViewModel.forBackground(...)
return .video(viewModel, ...)

This is consistent with the rest of the codebase - early validation catches unsupported conditions, and video backgrounds use a dedicated non-throwing path since they have no overrides to validate.

- Add VideoComponentViewModel.forBackground() for video backgrounds
- Video backgrounds don't have overrides, so no validation needed
- Remove try? fallback pattern in DisplayableColor.swift
- Consistent with other components: early validation, non-throwing where safe

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@RevenueCat-Danger-Bot

RevenueCat-Danger-Bot commented Feb 23, 2026

Copy link
Copy Markdown
1 Warning
⚠️ Please keep RevenueCat.xcodeproj in sync with Tuist-generated changes.

The following Swift files were added but don't appear to be included in RevenueCat.xcodeproj:
• Tests/RevenueCatUITests/PaywallsV2/ToPresentedOverridesTests.swift

If you've changed files using the tuist project, make sure those changes are added to RevenueCat.xcodeproj, or double-check if they should be excluded.

Generated by 🚫 Danger

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread RevenueCatUI/Templates/V2/ViewModelHelpers/PresentedPartials.swift

/// Creates a view model for video backgrounds, which don't have overrides.
/// This is non-throwing because video backgrounds are constructed without overrides.
static func forBackground(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice

Resolve conflict in PresentedPartials.swift by adopting the new
CustomVariableValue property accessors (isString, isBool, isNumber,
stringValue, boolValue, doubleValue) from the base branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@facumenzella facumenzella merged commit 7f94cc2 into facundo/coco Feb 23, 2026
1 of 2 checks passed
@facumenzella facumenzella deleted the facundo/coco-4 branch February 23, 2026 17:09
facumenzella added a commit that referenced this pull request Mar 6, 2026
* [Conditional Configurability][1] Add new condition types for conditional configurability

Add ExtendedCondition enum as @_spi(Internal) to support new condition types
while keeping the public Condition API stable. This includes:

- ExtendedCondition enum with associated values for variableCondition,
  selectedPackageCondition, extended introOffer/promoOffer conditions
- EqualityOperator and ArrayOperator enums for condition evaluation
- ConditionValue enum for type-safe variable values
- ComponentOverride now stores ExtendedCondition internally, exposes
  public Condition via computed property
- Updated PresentedPartials to use ExtendedCondition
- Comprehensive deserialization tests

The public Condition enum remains unchanged as String raw-value to
maintain API stability. New condition types map to .unsupported in
the public API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix CI: Add @_spi(Internal) import to PresentedPartialsTests

The existing test file needs SPI access to use ExtendedCondition
cases after the restructuring for conditional configurability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add missing deserialization error handling tests

Match Android test coverage for edge cases:
- Unknown operator falls back to unsupported
- Wrong field types fall back to unsupported
- Empty JSON object falls back to unsupported
- JSON without type field falls back to unsupported

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix ExtendedCondition decoder to handle missing type field gracefully

The decoder now wraps the entire decoding logic in a do-catch block,
so that empty JSON objects or JSON without a "type" field fall back
to `.unsupported` instead of throwing a keyNotFound error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* same line

* Add clarifying comment about Condition's unused Codable implementation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add ConditionDeserializationTests.swift to Xcode project

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Simplify ExtendedCondition by removing redundant legacy cases

Normalize legacy intro_offer/promo_offer conditions to their extended form
(operator: .equals, value: true) during deserialization instead of having
separate cases for legacy and extended forms.

This simplifies the enum and evaluation logic while maintaining full
backwards compatibility with legacy JSON.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove redundant Condition suffix from ExtendedCondition cases

Rename for consistency with other cases (.compact, .medium, etc.):
- introOfferCondition → introOffer
- promoOfferCondition → promoOffer
- variableCondition → variable
- selectedPackageCondition → selectedPackage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [Conditional Configurability][2] Implement `selected_package` condition evaluation (#6286)

* [Conditional Configurability][2] Add ConditionContext and evaluation logic

- Add ConditionContext struct for passing evaluation context
- Add buildPartial overload that accepts ConditionContext
- Add shouldApply overload with full condition evaluation
- Add evaluateCondition for all condition types
- Add helper methods for variable, package, and boolean condition evaluation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix availability annotations and CustomVariableValue usage

- Add @available(iOS 15.0, ...) to ConditionContext and related methods
- Fix matchesValue to use CustomVariableValue getters (.stringValue,
  .boolValue, .doubleValue) instead of pattern matching on private enum

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Simplify shouldApply by delegating to iOS 15+ version

The else branch is dead code since Paywalls is iOS 15+ anyway.
This consolidates the condition evaluation logic in one function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* [Conditional Configurability][3] Implement variable and extended intro/promo condition evaluation (#6287)

* [Conditional Configurability][3] Add condition evaluation tests

Add comprehensive tests for the condition evaluation logic:
- Selected package condition tests (in/not in operators)
- Variable condition tests (string, int, not found)
- Extended intro offer condition tests (equals/not equals)
- Multiple conditions (AND logic) tests
- Unsupported condition tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add missing condition evaluation tests and fix availability

- Add promo offer condition tests with operators
- Add variable boolean, double, and type mismatch tests
- Add intro offer negative test case
- Fix @available annotations for ConditionContext and related methods
- Fix matchesValue to use CustomVariableValue getters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix type-strict variable condition evaluation and remove unrelated files

- Add isString, isNumber, isBool type checking methods to CustomVariableValue
- Update matchesValue to perform type-strict comparison (string != int, etc.)
- Remove accidentally committed PR_6285_review.md and package-lock.json
- Revert unrelated Package.resolved changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* [Conditional Configurability][4] Validate unsupported conditions in toPresentedOverrides (#6288)

* [Conditional Configurability][3] Add condition evaluation tests

Add comprehensive tests for the condition evaluation logic:
- Selected package condition tests (in/not in operators)
- Variable condition tests (string, int, not found)
- Extended intro offer condition tests (equals/not equals)
- Multiple conditions (AND logic) tests
- Unsupported condition tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add missing condition evaluation tests and fix availability

- Add promo offer condition tests with operators
- Add variable boolean, double, and type mismatch tests
- Add intro offer negative test case
- Fix @available annotations for ConditionContext and related methods
- Fix matchesValue to use CustomVariableValue getters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix type-strict variable condition evaluation and remove unrelated files

- Add isString, isNumber, isBool type checking methods to CustomVariableValue
- Update matchesValue to perform type-strict comparison (string != int, etc.)
- Remove accidentally committed PR_6285_review.md and package-lock.json
- Revert unrelated Package.resolved changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [Conditional Configurability][4] Add unsupported condition detection

- Add `PaywallError.unsupportedCondition` case for future fallback support
- Add `containsUnsupportedConditions()` method to detect unsupported conditions
- Add logging string for unsupported condition warning
- Add comprehensive tests for unsupported condition detection

Note: The actual fallback mechanism (throwing and catching at paywall level)
will be implemented in a follow-up PR to avoid cascading changes to all
component ViewModels.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Make CustomVariableValue.number and .bool public

Allow developers to pass numeric and boolean custom variables to paywalls,
enabling condition evaluation based on these types.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update API tester to use public .number() and .bool() methods

The CustomVariableValue factory methods .number() and .bool() are now
public. Update the API tester to use these methods directly instead of
using .string() for all values.

Existing test coverage in VariableHandlerV2Tests.swift already covers
these factory methods comprehensively.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Integrate unsupported condition validation into toPresentedOverrides

This matches Android's approach where toPresentedOverrides checks for
unsupported conditions and throws PaywallError.unsupportedCondition,
triggering fallback to the default paywall.

Changes:
- toPresentedOverrides now throws when unsupported conditions are found
- Updated all view model initializers to be throwing
- Updated ViewModelFactory to use try when instantiating view models
- Used try? with fallback for video backgrounds in SwiftUI contexts
- Updated preview code with try!/force_try

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add tests for toPresentedOverrides throwing on unsupported conditions

Add test coverage verifying that toPresentedOverrides throws
PaywallError.unsupportedCondition when any override contains an
unsupported condition type.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [Conditional Configurability][5] PR comments and fallback paywall (#6319)

* Integrate unsupported condition validation into toPresentedOverrides

This matches Android's approach where toPresentedOverrides checks for
unsupported conditions and throws PaywallError.unsupportedCondition,
triggering fallback to the default paywall.

Changes:
- toPresentedOverrides now throws when unsupported conditions are found
- Updated all view model initializers to be throwing
- Updated ViewModelFactory to use try when instantiating view models
- Used try? with fallback for video backgrounds in SwiftUI contexts
- Updated preview code with try!/force_try

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* suggestions

^ Conflicts:
^	RevenueCatUI/Data/CustomPaywallVariables.swift
^	RevenueCatUI/Templates/V2/ViewModelHelpers/PresentedPartials.swift

* internal bool and number

* fallback paywall

* Fix compilation error and SwiftLint violations

- Fix call to renamed method: containsUnsupportedConditions -> hasUnsupportedCondition
- Rename variable 'c' to 'component' to satisfy identifier_name rule
- Add swiftlint:disable for cyclomatic_complexity

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove accidental .package.resolved file

* Remove extra blank lines

---------

Co-authored-by: Facundo Menzella <facumenzella@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Add non-throwing factory for video backgrounds

- Add VideoComponentViewModel.forBackground() for video backgrounds
- Video backgrounds don't have overrides, so no validation needed
- Remove try? fallback pattern in DisplayableColor.swift
- Consistent with other components: early validation, non-throwing where safe

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Cesar de la Vega <664544+vegaro@users.noreply.github.com>

* [bug-bash] Fix selectedPackage conditional visibility not working

The selectedPackage condition was never evaluated correctly because
components were calling buildPartial without passing ConditionContext.
This meant selectedPackageId was always nil during condition evaluation.

Updated all component ViewModels to:
- Accept selectedPackageId parameter in their styles() method
- Create ConditionContext with the selected package ID
- Pass conditionContext to buildPartial()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [bug-bash] Add warning log for unrecognized paywall condition types

Developers will now see a warning when the SDK encounters a condition type
it doesn't recognize, helping them identify when they need to update the SDK.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [bug-bash] Add support for multiple_intro_offers condition type

This condition is supported in Android. On iOS, it always evaluates to false
since iOS does not support multiple intro offers. Adding this prevents the
paywall from falling back to the default when this condition is present.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [bug-bash] Pass custom variables to ConditionContext for variable conditions

Custom variable conditions were always evaluating to false because
the customVariables dictionary was empty. Components now get the
customPaywallVariables from the SwiftUI environment and pass them
to their ViewModel's styles() method, which forwards them to
ConditionContext for proper condition evaluation.

Updated components: Stack, Image, Icon, Video, Timeline, Carousel.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* [bug-bash] Make number() and bool() public for CustomVariableValue

Developers need to be able to create numeric and boolean custom
variable values, not just strings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix tabs override condition conversion to preserve extended conditions (#6361)

* Add missing condition evaluation unit tests for PresentedPartials

Closes test coverage gap identified from Android PR #3156. Adds 15 new
test cases covering intro/promo offer negative cases, type safety,
override precedence, and cross-offer independence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add multiple_intro_offers compatibility guardrail tests for iOS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* add bool and number support in paywalls tester (#6394)

* Split intro/promo offer condition JSON keys for backward compatibility with older SDKs (#6397)

Splits legacy boolean conditions (introOffer/promoOffer) from operator-based ones
(introOfferCondition/promoOfferCondition) and updates JSON keys so old SDKs safely
ignore new condition types. Also renames variable → variable_condition and
selected_package → selected_package_condition.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Review fixes: remove multipleIntroOffers from public API, restore private storage, epsilon double comparison

- Remove `multipleIntroOffers` from public `Condition` enum to avoid source-breaking
  change on @Frozen enum. It remains in `ExtendedCondition` and maps to `.unsupported`.
- Restore `Storage` and `storage` to `private` on `CustomVariableValue` — condition
  evaluation uses the existing `isString`/`isNumber`/`isBool` helpers instead.
- Replace exact `==` double comparison with epsilon-based `doublesMatch` to handle
  floating point representation differences from JSON round-trips.
- Add tests for epsilon comparison edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Remove unused legacy buildPartial and shouldApply overloads

All callers use the new buildPartial with conditionContext parameter.
Remove the legacy overload (without conditionContext) and its shouldApply
wrapper that had an unnecessary #available gate returning false on pre-iOS 15.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix condition evaluation not using dashboard default custom variables

ConditionContext was only receiving developer-provided custom variables
from the SwiftUI environment, but not the dashboard-configured defaults.
This caused variable-based conditions (e.g. "something == false") to
always fail when the developer didn't explicitly provide the variable,
even if a default was set in the dashboard.

The fix merges defaultCustomVariables into ConditionContext at init time
(developer values take priority), and passes them from all 8 view model
sites that create ConditionContext.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Wire up conditional configurability for TabsComponent

TabsComponentViewModel had presentedOverrides stored but never evaluated.
Added a styles() method that creates a ConditionContext, calls buildPartial,
and returns a TabsComponentStyle with overrides applied. The view now
evaluates conditions and checks visibility before rendering.

Also updated TabsComponentStyle.init to accept Background? instead of
ColorScheme? to match the actual data model, and added a clarifying
comment to CountdownComponentViewModel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add tests for intro/promo offer conditions with wrong value types

Verify that conditions with non-boolean values (e.g., string instead of
bool) gracefully fall back to .unsupported, triggering the fallback paywall.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Disable autocapitalization on custom variables value TextField

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add bug bash unit tests for conditional configurability (#6398)

Add unit tests derived from the bug bash test plan to cover:
- Override precedence with visibility (two/three overrides, last-matching wins)
- Same condition evaluated independently on multiple components
- Condition + selected state interaction
- Variable match/mismatch for text replacement scenarios
- Intro offer with different eligibility states
- Different condition types on sibling components
- containsUnsupportedConditions for carousel, tabs, button, package, deep nesting

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Add Emerge snapshot previews for conditional configurability (#6400)

* Add Emerge snapshot previews for conditional configurability

Add SwiftUI previews that test basic show/hide behavior using
variable conditions on Text and Stack components. These will be
automatically picked up by Emerge's SnapshotPreviews for visual
regression testing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Improve snapshot preview names for easier debugging

Make display names include the condition, operator, value, and expected
outcome so broken snapshots can be diagnosed at a glance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add ConditionalConfigurabilityPreview.swift to xcodeproj

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix notEquals preview: use matching variable value so condition triggers

The preview set tier="free" with a notEquals "free" condition, which
evaluates to false — the override never applied. Changed to tier="premium"
so the condition matches and the text is correctly hidden.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Show default paywall instead of fallback for unsupported conditions (#6406)

* Show default paywall instead of fallback when unsupported conditions found

Per the spec, when the SDK encounters condition types it doesn't
recognize, it should render the same V2 paywall with only legacy
overrides applied — not fall back to a completely different V1 paywall.

When any unsupported condition is found, all rule-based overrides
(variable, selected_package, intro_offer_condition,
promo_offer_condition, and unsupported) are discarded. Only legacy
overrides (compact, medium, expanded, selected, introOffer,
promoOffer, multipleIntroOffers) are kept. This aligns with Android
PR #3175.

Changes:
- Add `isRule` property to ExtendedCondition to distinguish
  conditional configurability rules from legacy base conditions
- Update toPresentedOverrides to filter out all rule-based overrides
  when any unsupported condition is present
- Remove throw from PaywallsV2View (keep warning log)
- Remove PaywallError.unsupportedCondition (no longer thrown)
- Update log message to explain overrides will be ignored

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Propagate discardRules globally when any component has unsupported conditions

When any component in the paywall tree contains unsupported conditions,
all rule-based overrides are now discarded globally across every component,
not just per-component. This matches the spec requirement for rendering the
"default paywall" with only legacy overrides applied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Classify .unsupported as non-rule since it pre-dates conditional configurability

Only the extended conditions introduced by conditional configurability
(variable, selectedPackage, introOfferCondition, promoOfferCondition) are
classified as rules. .unsupported existed before coco as a fallback for
unrecognized condition types and always evaluates to false at runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix button sheet detection, add cross-subtree tests, align log wording

- Fix containsUnsupportedConditions() to check button sheet destination
  stacks, not just the button's own stack
- Add cross-subtree integration tests: unsupported in button sheet and
  nested tabs triggers global discard on sibling components
- Update warning log to match Android: "Unsupported paywall rule
  encountered. Rendering paywall without conditional configurability rules."

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Remove redundant local hasUnsupportedCondition check from toPresentedOverrides

The global discardRules flag already walks the entire component tree,
so the per-component hasUnsupportedCondition() fallback in
toPresentedOverrides was redundant. Simplify to only check discardRules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Recurse into timeline item sub-components for unsupported condition detection

TimelineComponent.containsUnsupportedConditions() was only checking
the timeline's own overrides and each item's direct overrides, but not
recursing into item.title, item.description, or item.icon. This meant
unsupported conditions in those sub-components wouldn't set the global
discardRules flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Address review feedback: drop unsupported overrides, deduplicate tree walk, add @_spi

- Filter also drops .unsupported overrides when discardRules is true
- Move warning log after factory call, read factory.discardRules
  instead of traversing the component tree twice
- Mark isRule as @_spi(Internal)
- Add tests: discardRules drops .unsupported and mixed legacy+rule overrides

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Add malformed condition logging and fix missing test file in Xcode project

Log a warning when a known condition type fails to decode instead of
silently falling back to .unsupported. Also add ToPresentedOverridesTests.swift
to the Xcode project to fix the Danger bot missing-file warning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix selected_package condition evaluating against wrong package inside package components (#6412)

PackageComponentView overrides PackageContext for its children (for variable
processing), which caused selected_package conditions to always evaluate against
the package component's own ID instead of the globally selected package.

Fix: introduce a separate @Environment(\.selectedPackageId) key set at the root
that is NOT overridden by PackageComponentView. All component views now read
selectedPackageId from this environment key for condition evaluation.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Rename condOp to conditionOperator in PresentedPartials

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add SelectedPackageId.swift to RevenueCat.xcodeproj

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add .number() and .bool() to CustomVariableValue API tester (#6415)

These were promoted from internal to public in #6285.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Cesar de la Vega <664544+vegaro@users.noreply.github.com>
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.

3 participants