Skip to content

refactor(ios): remove clang VFS overlay, resolve headers via new ReactNativeHeaders framework#57285

Open
chrfalch wants to merge 2 commits into
mainfrom
chrfalch/remove-vfs-overlay
Open

refactor(ios): remove clang VFS overlay, resolve headers via new ReactNativeHeaders framework#57285
chrfalch wants to merge 2 commits into
mainfrom
chrfalch/remove-vfs-overlay

Conversation

@chrfalch

Copy link
Copy Markdown
Collaborator

Summary

The prebuilt React.xcframework previously relied on a Clang VFS overlay (React-VFS.yaml) to make headers importable, because the headers were laid out in CocoaPods-style namespaced folders rather than standard framework conventions. The overlay had to be generated at build time, re-resolved at pod-install time per slice, and injected as -ivfsoverlay flags into every Obj-C, C++, and Swift compile (including aggregate and third-party pod targets).

This is fragile, hard to reason about, and incompatible with SwiftPM consumption.

This PR removes the VFS overlay entirely and resolves headers through standard framework/header-search-path mechanics instead.

Headers are now emitted into the artifact according to an explicit, executable spec:

  • React.xcframework — each slice's React.framework carries every <React/...> header plus a framework module map, so #import <React/...> and @import React resolve through FRAMEWORK_SEARCH_PATHS automatically.
  • ReactNativeHeaders.xcframework (new, headers-only) — carries every other namespace (<react/...>, <yoga/...>, folly, glog, …), shipped alongside in the prebuilt tarball and exposed via a single header search path.
  • This makes ReactNativeDependencies binary-only.

No clang VFS overlay, no per-target -ivfsoverlay flags. The layout is driven by a single source of truth (headers-spec.js, rules R1–R8) that both the prebuild compose step and downstream SwiftPM tooling derive from, so the shipped header set cannot drift from the spec.

Source headers are byte-identical to the repo — the only consumer-facing changes needed is bare-form angle includes (#import <RCTAppDelegate.h>#import <React/RCTAppDelegate.h>).

Key changes

  • New: headers-spec.js (the executable layout contract), headers-compose.js (emitter for both xcframeworks), headers-inventory.js (podspec-driven header classifier feeding the spec + a diagnostic manifest).
  • Removed: vfs.js, VFS types in types.js, and the VFS processing/flag-injection paths in rncore.rb and xcframework.js.
  • Updated: React-Core-prebuilt.podspec (vends both xcframeworks, flattens ReactNativeHeaders headers into Headers/ via prepare_command), rncore.rb / react_native_pods.rb (header search path instead of overlay flags), README (VFS docs replaced with the new model).

Changelog

[IOS] [CHANGED] - Remove the Clang VFS overlay from prebuilt React Native Core; resolve headers via React.xcframework + a new headers-only ReactNativeHeaders.xcframework

Test Plan

  • rn-tester builds against the prebuilt React-Core-prebuilt pod (Debug + Release) with no -ivfsoverlay flags present in the generated xcconfigs.
  • rn-tester builds against React native source code (without any prebuilt artifacts)
  • #import <React/...>, @import React;, and the relocated namespaces (<react/...>, <yoga/...>, folly/glog) all resolve.
  • Prebuilt tarball contains both React.xcframework and ReactNativeHeaders.xcframework pod install flattens headers into React-Core-prebuilt/Headers.
  • Switch RN-tester between Debug/Release and verify that both React.xcframework and ReactNativeHeaders.xcframework are changed between debug and release correctly.

chrfalch and others added 2 commits June 19, 2026 11:07
The minimal machinery to build the packaged header structures:

- headers-spec.js: the executable layout contract (rules R1-R8) — which
  namespaces are hoisted into the React framework, which carry module maps,
  and how collisions are rejected.
- headers-inventory.js: scans the source tree and classifies every shipped
  header (language surface + modularizability bucket) — the input to the spec.
  computeInventory() feeds the build in-memory; the CLI writes a JSON manifest.
- headers-compose.js: emits the layout — writes the <React/...> headers +
  umbrella + module map into each React.framework slice (detected by the
  framework's presence), and assembles the headers-only
  ReactNativeHeaders.xcframework (every other namespace + deps + Hermes).
  Called by xcframework.js during compose.

This is the alternative header source that lets consumers resolve React Native
headers without a clang VFS overlay.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Emit the headers-spec layout unconditionally and delete the VFS overlay across
JS, CI publish, and Ruby. Consumers resolve headers the way the SwiftPM branch
does: <React/...> from the vendored React.framework, every other namespace from
ReactNativeHeaders. No root Headers/ on the xcframework, no VFS.

JS:
- xcframework.js: always emit the React.framework spec layout and build
  ReactNativeHeaders.xcframework (was gated behind RN_ZERO_I_LAYOUT=1). Remove
  the legacy header path entirely — the podspec->root-Headers enumeration,
  createModuleMapFile, and copyHeaderFilesToSlices — so the published
  React.xcframework is a standard framework (Info.plist + per-slice
  React.framework/{Headers,Modules}), no root Headers/ or Modules/. Ship
  ReactNativeHeaders.xcframework inside the reactnative-core tarball (sibling of
  React.xcframework) so the prebuilt pod can vend both; keep the standalone
  ReactNativeHeaders.xcframework.tar.gz for the SPM path. Drop the
  React-VFS-template.yaml emit and the ./vfs import.
- vfs.js: deleted (its only consumer was xcframework.js).
- types.js: drop the now-unused VFSEntry/VFSOverlay/HeaderMapping types.
- replace-rncore-version.js: drop the React-VFS.yaml preservation rationale.

Ruby/CocoaPods:
- React-Core-prebuilt.podspec: vend React.xcframework (its per-slice
  React.framework + module map serves <React/...> and @import React via
  FRAMEWORK_SEARCH_PATHS); flatten ReactNativeHeaders' headers into a top-level
  Headers/ in prepare_command and expose them via the pod header search path.
  Drop the VFS-era root header_mappings_dir/module_map.
- rncore.rb: remove the -ivfsoverlay injection and process_vfs_overlay;
  add_rncore_dependency and configure_aggregate_xcconfig now add a
  HEADER_SEARCH_PATHS to React-Core-prebuilt/Headers for podspec, aggregate, and
  third-party targets.
- react_native_pods.rb: drop the process_vfs_overlay post-install call.

Docs: replace the "VFS Overlay System" section with the headers-spec layout;
drop the obsolete "Known Issues" (pre-headers-spec) section.

Verified end-to-end: prebuild compose produces a VFS-free, root-Headers-free
React.xcframework; rn-tester pod install + xcodebuild (prebuilt path) BUILD
SUCCEEDED with zero -ivfsoverlay.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@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 Jun 19, 2026
@github-actions

Copy link
Copy Markdown

Caution

Missing Changelog

Please add a Changelog to your PR description. See Changelog format

// namespace). The headers-only xcframework is a sibling of React.xcframework.
execSync(
`tar -czf ${tarFilePath} -C ${path.dirname(outputPath)} React.xcframework`,
`tar -czf ${tarFilePath} -C ${path.dirname(outputPath)} React.xcframework ${path.basename(headersXcfw)}`,
frameworkLog('Creating tar file: ' + headersTarPath);
try {
execSync(
`tar -czf ${headersTarPath} -C ${path.dirname(headersXcfw)} ReactNativeHeaders.xcframework`,
@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 Jun 19, 2026
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. p: Expo Partner: Expo Partner 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.

2 participants