fix(apple): use compiler guards - #218
Conversation
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
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
802461b to
31f0285
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
packages/apple/Sources/Helpers/StoreKitTypesBridge.swiftpackages/apple/Sources/OpenIapModule.swiftpackages/apple/Tests/OpenIapTests/CompilerGuardTests.swift
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Summary
#if swift(>=...)guards.Closes #216
Test plan
swift test --filter CompilerGuardTestsfrompackages/appleswift build -Xswiftc -swift-version -Xswiftc 5frompackages/appleswift test --filter OpenIapTestsfrompackages/applebun audit:parityPreview
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