Skip to content

fix(ios): Swift header not found under Xcode 26 explicit modules - #278

Open
AurelienV-42 wants to merge 1 commit into
Purchasely:mainfrom
AurelienV-42:patch-1
Open

fix(ios): Swift header not found under Xcode 26 explicit modules#278
AurelienV-42 wants to merge 1 commit into
Purchasely:mainfrom
AurelienV-42:patch-1

Conversation

@AurelienV-42

Copy link
Copy Markdown

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:

'react_native_purchasely-Swift.h' file not found

pointing at PurchaselyRN.m's #import "react_native_purchasely-Swift.h".

Root cause

PurchaselyRN.m mixes Objective-C and Swift sources in the same CocoaPods target (it imports the compiler-generated Swift interface header to use PLYTransitionFactory, defined in PLYTransitionFactory.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 #import as 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_include so it falls back to the original quoted import wherever the module path isn't available (older Xcode, non-explicit-modules builds, etc.):

#if __has_include(<react_native_purchasely/react_native_purchasely-Swift.h>)
#import <react_native_purchasely/react_native_purchasely-Swift.h>
#else
#import "react_native_purchasely-Swift.h"
#endif

The module-qualified form lets Clang's explicit-module scanner resolve it as a real dependency on the react_native_purchasely module, 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. disabling SWIFT_ENABLE_EXPLICIT_MODULES/CLANG_ENABLE_EXPLICIT_MODULES for the pod target) was needed once this import is fixed.

Add conditional import for Swift header based on availability.
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

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

  • Adds an __has_include guard around the generated Swift interface import.
  • Uses the pod module path when available and retains compatibility with non-modular CocoaPods layouts.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The module-qualified import is selected only when available, and the unchanged quoted import remains as a compatibility fallback for non-modular CocoaPods builds.

Important Files Changed

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

Copy link
Copy Markdown

Heads up: this fix unblocks a stuck batch of 7 open Dependabot PRs (#271#277) — every one of them fails build-ios with the exact symptom described here (Xcode 26 explicit-modules, react_native_purchasely-Swift.h not found). Full tracking/table is on #271 since Issues are disabled on this repo. No action needed here beyond normal review — just flagging the downstream impact of merging this.


Generated by Claude Code

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.

2 participants