Skip to content

fix(apple): add watchOS platform compatibility#81

Merged
hyochan merged 3 commits intomainfrom
fix/apple-watchos-compatibility
Feb 12, 2026
Merged

fix(apple): add watchOS platform compatibility#81
hyochan merged 3 commits intomainfrom
fix/apple-watchos-compatibility

Conversation

@hyochan
Copy link
Member

@hyochan hyochan commented Feb 12, 2026

Summary

  • Use #if os(iOS) || os(tvOS) instead of canImport(UIKit) for UIWindowScene (not available on watchOS)
  • Use #if os(iOS) for presentCodeRedemptionSheet (iOS-only API)
  • Use #if os(iOS) || os(tvOS) || os(visionOS) for UIApplication.open (not available on watchOS/macOS)
  • Add watchOS 9.0 to @available for getAppTransactionIOS (AppTransaction requires watchOS 9.0+)
  • Add tvOS 16.0 to @available annotations for consistency

Fixes watchOS build errors that occurred after merging #80.

Test plan

  • Validated with pod lib lint openiap.podspec --allow-warnings
  • CI build passes for all platforms (iOS, macOS, tvOS, watchOS)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for tvOS 16.0 and watchOS 9.0 platforms.
  • Improvements

    • Enhanced platform detection logic across Apple devices for better compatibility.

- Use #if os(iOS) || os(tvOS) instead of canImport(UIKit) for UIWindowScene
- Use #if os(iOS) for presentCodeRedemptionSheet (iOS-only API)
- Use #if os(iOS) || os(tvOS) || os(visionOS) for UIApplication.open
- Add watchOS 9.0 to @available for getAppTransactionIOS (requires AppTransaction)
- Add tvOS 16.0 to @available annotations for consistency

Fixes watchOS build errors caused by UIKit APIs not available on watchOS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Warning

Rate limit exceeded

@hyochan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The PR extends Apple package platform support to tvOS and watchOS by updating availability annotations and platform detection logic. Release workflows are updated to support a "current" version option that skips version bumping when redeploying without code changes.

Changes

Cohort / File(s) Summary
Release Workflow Updates
.github/workflows/release-apple.yml, .github/workflows/release-google.yml
Adds "current" version bump option to conditionally skip version commits, file syncing, and tag updates when redeploying existing versions.
Platform Availability Expansion
packages/apple/Sources/OpenIapModule+ObjC.swift, packages/apple/Sources/OpenIapProtocol.swift, packages/apple/Sources/OpenIapStore.swift
Extends @available annotations for getAppTransactionIOS method to include tvOS 16.0 and watchOS 9.0 alongside existing iOS 16.0 and macOS 14.0 support.
Platform Gate Refactoring
packages/apple/Sources/OpenIapModule.swift
Replaces canImport(UIKit) platform gates with explicit OS checks (os(iOS), os(tvOS), os(macOS), os(visionOS)) for more precise platform targeting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #80: Modifies identical Apple package files to broaden availability annotations and update platform support markers.
  • #15: Updates Apple package source files and bumps version configurations with related platform compatibility changes.

Suggested labels

🛠 bugfix, :inbox_tray: compatibility, 📱 iOS

Poem

🐰 Hops with glee, tvOS and watchOS now play,
Platform gates refined to light the way,
Version bumps skip when they need to stay,
Apple devices dance in broader display!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(apple): add watchOS platform compatibility' directly aligns with the main change in the pull request—adding watchOS 9.0 platform support and fixing watchOS build errors by updating availability annotations and platform-specific guards.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/apple-watchos-compatibility

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 and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @hyochan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses and resolves watchOS build errors that were introduced by a previous merge, significantly enhancing the library's overall platform compatibility. It refactors conditional compilation logic to utilize more precise os() checks instead of canImport() for UIKit and AppKit, ensuring that platform-specific APIs are correctly included or excluded for iOS, tvOS, watchOS, and macOS. Additionally, @available annotations have been updated to accurately reflect API availability across various Apple operating systems, particularly for getAppTransactionIOS and related functionalities.

Highlights

  • Enhanced Platform Compatibility: Updated conditional compilation directives from canImport(UIKit) to more precise os(platform) checks for UIWindowScene and UIApplication.open to correctly exclude watchOS, resolving build errors.
  • Refined API Availability: Adjusted the presentCodeRedemptionSheetIOS method's platform availability check to specifically target iOS, as it is an iOS-only API.
  • Extended @available Annotations: Extended @available annotations for getAppTransactionIOS and related methods to include watchOS 9.0 and tvOS 16.0, ensuring accurate API availability across Apple platforms.
  • Consistent Conditional Compilation: Replaced canImport(AppKit) with #if os(macOS) for macOS-specific code blocks, standardizing platform checks.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/apple/Sources/OpenIapModule+ObjC.swift
    • Updated @available annotation for getAppTransactionIOSWithCompletion to include tvOS 16.0 and watchOS 9.0.
  • packages/apple/Sources/OpenIapModule.swift
    • Replaced canImport(UIKit) with #if os(iOS) || os(tvOS) for UIWindowScene usage.
    • Replaced canImport(AppKit) with #if os(macOS) for macOS-specific code.
    • Updated presentCodeRedemptionSheetIOS to use #if os(iOS) for platform checks.
    • Updated presentExternalPurchaseLinkIOS to use #if os(iOS) || os(tvOS) || os(visionOS) for UIApplication.open availability.
  • packages/apple/Sources/OpenIapProtocol.swift
    • Updated @available annotation for getAppTransactionIOS to include tvOS 16.0 and watchOS 9.0.
  • packages/apple/Sources/OpenIapStore.swift
    • Updated @available annotation for getAppTransactionIOS to include tvOS 16.0 and watchOS 9.0.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

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 effectively addresses watchOS build errors by replacing broad canImport checks with more specific os() conditions. The changes correctly handle platform-specific API availability for UIWindowScene, presentCodeRedemptionSheet, and UIApplication.open. Additionally, the @available attributes have been updated to include watchOS and ensure consistency across platforms. I have one suggestion to include visionOS in a platform check to further improve compatibility.

- Add 'current' to version choice options for both Apple and Google workflows
- Skip version bump/commit when 'current' is selected
- Allow tag reuse in Google workflow when using 'current' mode
- Enables easy retry after partial deployment failures

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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/release-google.yml (1)

350-355: ⚠️ Potential issue | 🟡 Minor

gh release create will fail if the release already exists during a retry.

Unlike the Apple workflow (lines 297–303) which checks gh release view before creating, the Google workflow unconditionally calls gh release create. In current mode (retrying a partial deployment), the GitHub release may already exist from a previous run, causing this step to fail.

Suggested fix: guard release creation like the Apple workflow
-        gh release create "google-$VERSION" \
-          $ARTIFACTS \
-          --title "Google $VERSION" \
-          --latest \
-          --notes-file /tmp/release-notes.md
+        if gh release view "google-$VERSION" >/dev/null 2>&1; then
+          echo "ℹ️ Release google-$VERSION already exists. Skipping creation."
+        else
+          gh release create "google-$VERSION" \
+            $ARTIFACTS \
+            --title "Google $VERSION" \
+            --latest \
+            --notes-file /tmp/release-notes.md
+        fi
🧹 Nitpick comments (2)
packages/apple/Sources/OpenIapModule.swift (1)

344-376: Consider including visionOS in the UIWindowScene branch.

UIWindowScene is available on visionOS, so #if os(iOS) || os(tvOS) excludes visionOS from the confirmIn: purchase flow. visionOS will fall through to the #else branch (plain product.purchase(options:)), which works but skips the enhanced confirmation UI.

If this is intentional to keep the PR scoped to the watchOS fix, that's fine — but it may be worth a follow-up.

Optional: include visionOS
-            `#if` os(iOS) || os(tvOS)
-            // iOS/tvOS: Use UIWindowScene (not available on watchOS)
+            `#if` os(iOS) || os(tvOS) || os(visionOS)
+            // iOS/tvOS/visionOS: Use UIWindowScene (not available on watchOS)
packages/apple/Sources/OpenIapModule+ObjC.swift (1)

627-651: Note: #if !os(tvOS) doesn't exclude watchOS for the ObjC bridge.

The compile-time guard at line 627 excludes tvOS but still compiles presentCodeRedemptionSheetIOSWithCompletion on watchOS. This is safe because the underlying presentCodeRedemptionSheetIOS() (in OpenIapModule.swift line 1070) has #if os(iOS) and throws .featureNotSupported on non-iOS platforms at runtime. Consider tightening this to #if os(iOS) or #if !os(tvOS) && !os(watchOS) for compile-time clarity.

Add visionOS to the platform conditional for UIWindowScene usage
since visionOS also supports UIWindowScene and purchase(confirmIn:).

Addresses PR review comment from gemini-code-assist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hyochan hyochan merged commit 312822c into main Feb 12, 2026
7 checks passed
@hyochan hyochan deleted the fix/apple-watchos-compatibility branch February 12, 2026 04:08
hyochan added a commit to hyochan/expo-iap that referenced this pull request Feb 12, 2026
## Summary

- Sync with OpenIAP apple 1.3.15
- Includes watchOS platform compatibility fixes
- iOS 15 compatibility for priceFormatStyle API

## Related

- OpenIAP PR: hyodotdev/openiap#81
- OpenIAP Release: https://cocoapods.org/pods/openiap

## Changes

- Update openiap-versions.json (apple: 1.3.14 → 1.3.15)

## Test Plan

- [x] `bun run lint:ci` passes
- [x] `bun run test` passes (221 tests)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Updated Apple package version to 1.3.15.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
hyochan added a commit to hyochan/react-native-iap that referenced this pull request Feb 12, 2026
## Summary

- Sync with OpenIAP apple 1.3.15
- Includes watchOS platform compatibility fixes
- iOS 15 compatibility for priceFormatStyle API
- visionOS support for UIWindowScene

## Related

- OpenIAP PR: hyodotdev/openiap#81
- OpenIAP Release: https://cocoapods.org/pods/openiap

## Changes

- Update openiap-versions.json (apple: 1.3.14 → 1.3.15)
- NitroIap.podspec automatically uses new version

## Test Plan

- [x] `yarn typecheck` passes
- [x] `yarn test` passes (244 tests)
- [x] Pre-commit checks passed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
  * Updated Apple component version to 1.3.15.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant