Skip to content

fix(apple): use compiler guards - #218

Merged
hyochan merged 3 commits into
mainfrom
fix/apple-storekit-compiler-guards
Jul 9, 2026
Merged

hyochan merged 3 commits into
mainfrom
fix/apple-storekit-compiler-guards

Conversation

@hyochan

@hyochan hyochan commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Compile StoreKit feature guards against the Swift compiler toolchain instead of the target Swift language mode.
  • Fix the newly active StoreKit 2 code paths for Xcode 26.5 SDK signatures, including JWS promotional offer options and Advanced Commerce mapping.
  • Add a regression test that fails if Apple StoreKit feature code reintroduces #if swift(>=...) guards.

Closes #216

Test plan

  • swift test --filter CompilerGuardTests from packages/apple
  • swift build -Xswiftc -swift-version -Xswiftc 5 from packages/apple
  • swift test --filter OpenIapTests from packages/apple
  • bun audit:parity

Preview

No recording attached: this is a native compile-guard and StoreKit bridge compatibility fix with no visual or interactive surface. Terminal verification is listed above.

Summary by CodeRabbit

  • Bug Fixes
    • Improved subscription offer and renewal detail extraction to make purchase flows more consistent.
    • Updated construction of signature-based promotional and introductory offers for better compatibility.
    • Refined advanced commerce info serialization for clearer, more reliable pricing and refund handling.
    • Expanded transaction property handling across additional Apple platforms.
  • Tests
    • Added coverage to detect and prevent stale Swift compiler-guard patterns from reappearing.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/apple-storekit-compiler-guards

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors compiler guards in the Apple package to use #if compiler(>=...) instead of #if swift(>=...) to prevent modern toolchain code from being stripped in Swift 5 language-mode builds, and adds a compiler guard unit test to enforce this. It also extracts the retrieval of renewal offer info into a helper function and implements robust JSON compaction for advanced commerce transaction details. Feedback on the changes suggests improving renewalOfferInfoIOS to handle nil offers more defensively and fall back to deprecated properties, as well as extending compactJSONDictionary to support compacting arrays of nested dictionaries.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/apple/Sources/Helpers/StoreKitTypesBridge.swift
Comment thread packages/apple/Sources/Helpers/StoreKitTypesBridge.swift
Compile StoreKit feature paths based on the Swift compiler toolchain instead of the target Swift language mode so Swift 5 language-mode apps do not strip newer StoreKit code when built with capable Xcode versions.

Also align the newly compiled StoreKit 2 API paths with the Xcode 26.5 SDK signatures and add a regression test for compiler guards.

Closes #216
@hyochan
hyochan force-pushed the fix/apple-storekit-compiler-guards branch from 802461b to 31f0285 Compare July 9, 2026 13:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/apple/Sources/Helpers/StoreKitTypesBridge.swift`:
- Around line 469-474: The fallback branches in StoreKitTypesBridge for
compiler-unavailable purchase options are using the wrong error code. Update the
throws in the JWS promotional offers path (and the other matching
availability-only branches like the one around billing-plan handling) to return
PurchaseError with code .featureNotSupported instead of .developerError, while
keeping the existing log/message context in the affected helper logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eac14806-daaa-481f-9f8a-162ac72c404d

📥 Commits

Reviewing files that changed from the base of the PR and between 71e1755 and 802461b.

📒 Files selected for processing (3)
  • packages/apple/Sources/Helpers/StoreKitTypesBridge.swift
  • packages/apple/Sources/OpenIapModule.swift
  • packages/apple/Tests/OpenIapTests/CompilerGuardTests.swift

Comment thread packages/apple/Sources/Helpers/StoreKitTypesBridge.swift Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces #if swift(>=...) checks with #if compiler(>=...) to prevent modern toolchain code from being stripped in Swift 5 language-mode builds, and adds a unit test to enforce this. It also refactors renewal offer info extraction and introduces helpers to serialize advanced commerce info (iOS 18.4+) to JSON. A compilation issue was identified where the new decimalString helper expects a non-optional Decimal but is called with optional Decimal? properties; updating this helper to accept optionals is recommended.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/apple/Sources/Helpers/StoreKitTypesBridge.swift Outdated
@hyodotdev hyodotdev deleted a comment from coderabbitai Bot Jul 9, 2026
@hyodotdev hyodotdev deleted a comment from coderabbitai Bot Jul 9, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces #if swift(>=...) compiler guards with #if compiler(>=...) across the Apple package to ensure Swift 5 language-mode builds do not strip modern toolchain code. It also extracts renewalOfferInfoIOS into a helper function, introduces robust decimal string formatting and JSON serialization helpers for advanced commerce info (iOS 18.4+), and adds a new unit test suite CompilerGuardTests to prevent future regressions of the compiler guard pattern. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@hyochan
hyochan merged commit cdcf73e into main Jul 9, 2026
9 checks passed
@hyochan
hyochan deleted the fix/apple-storekit-compiler-guards branch July 9, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠 bugfix All kinds of bug fixes 🔥 hotfix Hot urgent pr 📥 compatibility 📱 iOS Related to iOS

Projects

None yet

1 participant