fix(ios): Swift header not found under Xcode 26 explicit modules - #278
fix(ios): Swift header not found under Xcode 26 explicit modules#278AurelienV-42 wants to merge 1 commit into
Conversation
Add conditional import for Swift header based on availability.
Greptile SummaryThis PR conditionally prefers the module-qualified generated Swift header to support Xcode 26 explicit-module dependency scanning while preserving the existing quoted import as a fallback.
|
| Filename | Overview |
|---|---|
| packages/purchasely/ios/PurchaselyRN.m | Safely adds a guarded module-qualified Swift header import without changing the fallback behavior of existing build configurations. |
Reviews (1): Last reviewed commit: "fix(ios): Swift header not found under X..." | Re-trigger Greptile
|
Heads up: this fix unblocks a stuck batch of 7 open Dependabot PRs (#271–#277) — every one of them fails Generated by Claude Code |
Problem
Building an app that depends on
react-native-purchasely(6.0.0) under Xcode 26, with the default "Explicitly Built Modules" build setting, fails with:pointing at
PurchaselyRN.m's#import "react_native_purchasely-Swift.h".Root cause
PurchaselyRN.mmixes Objective-C and Swift sources in the same CocoaPods target (it imports the compiler-generated Swift interface header to usePLYTransitionFactory, defined inPLYTransitionFactory.swift). The import is a plain, quoted#import "...".Under Xcode 26's explicit module builds, Clang's dependency scanner doesn't treat a quoted, non-modular
#importas an edge to the pod's own module — so it has no guarantee that this target's Swift compilation (which emits the generated header) has run before the ObjC file is scanned/compiled. The header sometimes doesn't exist yet when the ObjC file needs it.Fix
Prefer the angle-bracket, module-qualified form of the import (
<react_native_purchasely/react_native_purchasely-Swift.h>), guarded with__has_includeso it falls back to the original quoted import wherever the module path isn't available (older Xcode, non-explicit-modules builds, etc.):The module-qualified form lets Clang's explicit-module scanner resolve it as a real dependency on the
react_native_purchaselymodule, so the Swift compile is correctly ordered before this file.Testing
Verified with a real
bun run ios(Expo / React Native 0.85, Xcode 26) build, install, and app launch on iOS Simulator — fails with the exact error above without this change, succeeds with it. No Podfile-level workaround (e.g. disablingSWIFT_ENABLE_EXPLICIT_MODULES/CLANG_ENABLE_EXPLICIT_MODULESfor the pod target) was needed once this import is fixed.