Skip to content

Avoid SwiftPM umbrella header layout errors in spm scaffold - #60283

Open
chiroro-jr wants to merge 1 commit into
react:mainfrom
chiroro-jr:fix/spm-scaffold-umbrella-header-subdirs
Open

chiroro-jr wants to merge 1 commit into
react:mainfrom
chiroro-jr:fix/spm-scaffold-umbrella-header-subdirs

Conversation

@chiroro-jr

Copy link
Copy Markdown

Summary:

When react-native spm scaffold infers publicHeadersPath from a podspec's source directory (for example "apple" for react-native-gesture-handler or "ios" for @react-native-masked-view/masked-view), SwiftPM treats <publicHeadersPath>/<SwiftName>.h (when no explicit module.modulemap is present) as an umbrella header and fails package resolution whenever any subdirectory sits next to it (such as apple/Handlers/ or ios/RNCMaskedView.xcodeproj/):

error: target '<SwiftName>' has invalid header layout: umbrella header found at '.../<dir>/<SwiftName>.h', but directories exist next to it: ...; consider removing them

This change detects when the inferred publicHeadersPath contains <SwiftName>.h alongside subdirectories (and no custom module.modulemap), keeps the original directory in headerSearchPaths, and reuses the scaffolder's existing include/<SwiftName>/ shim mirror (publicHeadersPath: "include") so SwiftPM loads a valid module layout and dependents can #import <SwiftName/Header.h>. SCAFFOLDER_VERSION is bumped from 22 to 23 so previously scaffolded manifests regenerate automatically.

Changelog:

[IOS] [FIXED] - Avoid SwiftPM umbrella-header-with-subdirectories layout errors in react-native spm scaffold

Test Plan:

  • Reproduced SwiftPM's invalid header layout error on a target with apple/MyLib.h beside apple/Sub/, and verified swift build succeeds with publicHeadersPath: "include" and include/MyLib/MyLib.h shim headers.
  • Added unit tests in packages/react-native/scripts/spm/__tests__/scaffold-package-swift-test.js covering:
    • redirecting publicHeadersPath to "include" when <SwiftName>.h sits next to subdirectories,
    • preserving publicHeadersPath when a custom module.modulemap exists,
    • writing include/<SwiftName>/<SwiftName>.h shims in scaffoldPackageSwiftForDep.
  • Ran:
    • ./node_modules/.bin/jest packages/react-native/scripts/spm/__tests__/ (25 suites, 1264 tests passing)
    • ./node_modules/.bin/flow check-contents packages/react-native/scripts/spm/scaffold-package-swift.js < packages/react-native/scripts/spm/scaffold-package-swift.js (No errors)
    • ./node_modules/.bin/eslint and ./node_modules/.bin/prettier --check on both modified files (clean)

@meta-cla

meta-cla Bot commented Nov 25, 2026

Copy link
Copy Markdown

Hi @chiroro-jr!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 25, 2026
@meta-cla

meta-cla Bot commented Nov 25, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 25, 2026

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant