Skip to content

Add watchOS support#940

Draft
AlvaroBrey wants to merge 6 commits into
mainfrom
watchos-targets
Draft

Add watchOS support#940
AlvaroBrey wants to merge 6 commits into
mainfrom
watchos-targets

Conversation

@AlvaroBrey

@AlvaroBrey AlvaroBrey commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

WIP

Fixes #126


Note

Medium Risk
Large multi-module platform expansion and refactor of Apple source sets around purchase APIs; risk is mitigated by CI watchOS builds/tests and explicit availability guards, but paywall/UI modules remain iOS-only and behavior differs on watch for several StoreKit-adjacent APIs.

Overview
Adds watchOS as a supported Apple target for the core purchase SDK (core, models, mappings, kn-core, result, and partial either), and documents platform limits (no -ui / paywalls on watch; -either skips watchosDeviceArm64).

KMP layout: Apple-specific code moves from iosMain to appleMain, with iosMain / watchosMain handling APIs that exist only on one Apple OS (e.g. code redemption sheet and StoreKit in-app messages on iOS; log-only stubs on watchOS). Shared Purchases Apple implementation lives in appleMain with expect/actual hooks for those differences.

Build & CI: New watchosTargets() convention, Swift/cinterop updates (watchOS SDK paths, arm64_32 vs arm64 triples, removal of legacy watchosX64), UnsafeNumber opt-in for shared Apple cinterop, and a parallel build-and-test-watchos CircleCI job (compile + watchosSimulatorArm64Test). Generated error mappings path changes to mappings/.../appleMain/....

Interop fixes: Mapping changes for 32-bit watchosArm64 (NSInteger, price longLongValue, ad revenue clamping). Public KDoc notes watchOS behavior for win-back, in-app messages, and code redemption.

Reviewed by Cursor Bugbot for commit 0183d74. Bugbot is set up for automated code reviews on this repo. Configure here.

- Fix watchosArm64 triple: Kotlin/Native's watchosArm64 is arm64_32
- Add watchOS linkerOpts to the generated cinterop def file
- Add watchosTargets() helper for module build scripts
- Opt apple/watchos source sets into ExperimentalForeignApi
…orArm64)

- Rename iosMain/iosTest source sets to appleMain/appleTest in core,
  mappings and kn-core
- Split presentCodeRedemptionSheet and showInAppMessagesIfNeeded into
  iosMain/watchosMain actuals: the native APIs don't exist on watchOS
- Make mappings arm64_32-safe (NSInteger is 32 bits there)
- either skips watchosDeviceArm64: arrow-core doesn't publish it
- watchosX64 not added: removed in Kotlin 2.3.20
- Regenerate klib ABI dumps

Fixes #126
- Build and test watchOS archs in CI
- Move generated errors file path to appleMain
- Document watchOS support (ui module stays iOS-only)
NSInteger commonizes to a variable-width type once watchosArm64
(arm64_32) is in the target set, which requires this opt-in in
appleMain. Also compile the commonized metadata in CI, since it
otherwise only compiles at publish time.
@AlvaroBrey AlvaroBrey added the pr:feat A new feature label Jul 22, 2026
@AlvaroBrey AlvaroBrey self-assigned this Jul 22, 2026
…ings and instances, drop dead watchosX64 branches

- Clamp instead of sign-wrap for revenueMicros on 32-bit NSInteger
- Share one AppleApiAvailability instance per file, extract repeated
  requirement messages into consts, align and/or wording with KDoc
- Fix showStoreMessagesIfAvailable KDoc: the iOS actual does not log
  on older OS versions
- Remove WATCHOS_X64 branches: Kotlin 2.3.20 removed the target
- README: note either has no watchosDeviceArm64 variant
Self-contained (no workspace) so it can't conflict with the iOS
chain's persisted build output. iOS jobs return to their previous
shape.
@AlvaroBrey

Copy link
Copy Markdown
Contributor Author

@cursor review

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0183d74. Configure here.

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

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WatchOS target

1 participant