Skip to content

[iOS] New StoreKit 2 / Commitment features are silently stripped out (Silent Fail) if Project Swift Language Mode is lower than 6.3 (even on Xcode 26.5+) #216

Description

@thaitd0396

Description:

  1. Expected Behavior
    When building the application using a modern Xcode version (which bundles the necessary SDKs for new StoreKit 2 / Commitment features), the code inside the conditional blocks should be compiled and executed properly, regardless of whether the host project targets an older Swift Language Mode for backward compatibility.

  2. Actual Behavior
    The code inside the conditional block is completely stripped out / ignored at build time, leading to a silent failure during runtime (parameters like pricingTerms or billingPlanType return as null/missing).

This happens because the library uses #if swift(>=6.3) (or similar high version) to guard the code. If the main host application sets Swift Language Version = 5.9 in Xcode Build Settings to keep older dependencies stable, this condition evaluates to FALSE, forcing the compiler to ignore the block entirely—even though the Xcode toolchain itself is fully capable of compiling it.

  1. Root Cause
    #if swift(>=X.X) checks the Swift Language Mode specified in the target's Build Settings (which is 5.9 in our case).

#if compiler(>=X.X) checks the actual capability of the compiler toolchain bundled with Xcode.

Using #if swift instead of #if compiler mistakenly locks out modern SDK features from being compiled just because the project maintains backward compatibility via language mode.

  1. Steps to Reproduce
    Use a modern Xcode version (e.g., Xcode 16+ / Xcode 26.5+).

Set the main project's Swift Language Version to 5.9 in Build Settings.

Fetch a product that contains the new 12-month commitment / billing plan layout.

Notice that the properties are missing/null, and initiating a purchase results in a silent failure because the underlying native implementation was stripped out during the build.

  1. Suggested Fix
    Replace #if swift(>=...) with #if compiler(>=...) to check for toolchain/SDK availability rather than forcing the project's language mode to upgrade.

Before:

Swift

#if swift(>=6.3)
if #available(iOS 16.4, *) {
    let plan = product.billingPlanType
}
#endif

After:

Swift

#if compiler(>=6.3)
if #available(iOS 16.4, *) {
    let plan = product.billingPlanType
}
#endif

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions