-
Notifications
You must be signed in to change notification settings - Fork 25.2k
refactor(ios): remove clang VFS overlay, resolve headers via new ReactNativeHeaders framework #57285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chrfalch
wants to merge
17
commits into
main
Choose a base branch
from
chrfalch/remove-vfs-overlay
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactor(ios): remove clang VFS overlay, resolve headers via new ReactNativeHeaders framework #57285
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
68f9046
feat(ios): headers-spec layout + ReactNativeHeaders compose
chrfalch 705b310
refactor(ios): remove clang VFS overlay, resolve headers via frameworks
chrfalch 9ee4199
fix(ios): serve the react/ namespace as a module for SPM consumers
chrfalch 18735a0
fix(cocoapods): install prebuilt RNCore pods as header-less facades
chrfalch 02f3500
style: apply prettier to ios-prebuild scripts and docs
chrfalch 977f1ae
ci(ios): include ReactNativeHeaders.xcframework in the prebuilt core …
chrfalch ec979d3
feat(ios): expose allowlisted private React headers in the React modu…
chrfalch 556abab
feat(ios): emit per-namespace umbrella for React_RCTAppDelegate (R10)
chrfalch e53e6b2
fix(ios): re-vend RCTFabricComponentsPlugins.h from the React-RCTFabr…
chrfalch 42d8310
fix(ios-prebuild): fail closed when a deps namespace is missing from …
chrfalch 51d4e7e
fix(ios-prebuild): stage deps headers in compose-xcframework + sort t…
chrfalch 7b3be97
fix(ios): harden prebuilt header layout consumption (review findings)
chrfalch cd67dee
feat(ios-prebuild): generator-time headers gate + drift hardening (R1…
chrfalch e6ab638
style: prettier-format headers-rules.md (format-check lints md too)
chrfalch 6648f90
style: add language tags to headers-rules.md fenced blocks (markdownl…
chrfalch dcb5ad8
style: sort requires in headers-inventory.js (eslint sort-imports, ma…
chrfalch b4b1a94
fix(ios-prebuild): do not relocate SocketRocket headers into ReactNat…
chrfalch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,30 +11,16 @@ | |
|
|
||
| ### Adds ReactNativeCore-prebuilt as a dependency to the given podspec if we're not | ||
| ### building ReactNativeCore from source (then this function does nothing). | ||
| ### | ||
| ### `<React/...>` resolves through the vendored React.framework; every other namespace | ||
| ### (`<react/...>`, `<yoga/...>`, `<hermes/...>`, ...) resolves through the flattened | ||
| ### ReactNativeHeaders headers that React-Core-prebuilt exposes. The header search path | ||
| ### and the ReactNativeHeaders module-map activation are NOT added here: they are applied | ||
| ### post-install by configure_aggregate_xcconfig, which covers aggregate, third-party AND | ||
| ### these pods from a single injection site. No clang VFS overlay. | ||
| def add_rncore_dependency(s) | ||
| if !ReactNativeCoreUtils.build_rncore_from_source() | ||
| # Add the dependency | ||
| s.dependency "React-Core-prebuilt" | ||
|
|
||
| current_pod_target_xcconfig = s.to_hash["pod_target_xcconfig"] || {} | ||
| current_pod_target_xcconfig = current_pod_target_xcconfig.to_h unless current_pod_target_xcconfig.is_a?(Hash) | ||
|
|
||
| # Add VFS overlay flags for both Objective-C and Swift | ||
| # The VFS overlay file is pre-resolved at pod install time for each platform slice. | ||
| # We reference it directly in the xcframework using the React-VFS.yaml file that | ||
| # is written to the React-Core-prebuilt folder during setup_vfs_overlay. | ||
| # See scripts/ios-prebuild/__docs__/README.md for more details on VFS overlays. | ||
| vfs_overlay_flag = "-ivfsoverlay $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml" | ||
| current_pod_target_xcconfig["OTHER_CFLAGS"] ||= "$(inherited)" | ||
| current_pod_target_xcconfig["OTHER_CFLAGS"] += " #{vfs_overlay_flag}" | ||
| current_pod_target_xcconfig["OTHER_CPLUSPLUSFLAGS"] ||= "$(inherited)" | ||
| current_pod_target_xcconfig["OTHER_CPLUSPLUSFLAGS"] += " #{vfs_overlay_flag}" | ||
| # For Swift, we need to use -Xcc to pass flags to the underlying Clang compiler | ||
| # Both the flag and its argument need separate -Xcc prefixes | ||
| current_pod_target_xcconfig["OTHER_SWIFT_FLAGS"] ||= "$(inherited)" | ||
| current_pod_target_xcconfig["OTHER_SWIFT_FLAGS"] += " -Xcc -ivfsoverlay -Xcc $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml" | ||
|
|
||
| s.pod_target_xcconfig = current_pod_target_xcconfig | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -521,96 +507,65 @@ def self.get_nightly_npm_version() | |
| return latest_nightly | ||
| end | ||
|
|
||
| # Processes the VFS overlay file from the React.xcframework to resolve the ${ROOT_PATH} placeholder. | ||
| # This method should be called from react_native_post_install after pod install completes. | ||
| # Single post-install injection site for the prebuilt header resolution. Adds the | ||
| # ReactNativeHeaders search path + module-map activation to the aggregate (main app) | ||
| # target AND every pod target — RN core pods, third-party pods alike. (add_rncore_dependency | ||
| # only declares the React-Core-prebuilt dependency; it no longer touches xcconfigs.) | ||
| # | ||
| # The VFS overlay file maps header import paths to their actual locations within the xcframework. | ||
| # Since the xcframework contains platform-specific slices, we generate a resolved VFS file for each | ||
| # slice and also create a default VFS file that can be used immediately (before script phases run). | ||
| def self.process_vfs_overlay() | ||
| return if @@build_from_source | ||
|
|
||
| prebuilt_path = File.join(Pod::Config.instance.project_pods_root, "React-Core-prebuilt") | ||
| xcframework_path = File.join(prebuilt_path, "React.xcframework") | ||
| vfs_template_path = File.join(xcframework_path, "React-VFS-template.yaml") | ||
|
|
||
| unless File.exist?(vfs_template_path) | ||
| rncore_log("VFS overlay template not found at #{vfs_template_path}", :error) | ||
| exit 1 | ||
| end | ||
|
|
||
| rncore_log("Processing VFS overlay file...") | ||
|
|
||
| # Read the template content | ||
| vfs_template_content = File.read(vfs_template_path) | ||
|
|
||
| # Write the VFS file - use the top-level xcframework path | ||
| # so that ${ROOT_PATH}/Headers points to the xcframework's Headers folder | ||
| resolved_vfs_content = vfs_template_content.gsub('${ROOT_PATH}', xcframework_path) | ||
| resolved_vfs_path = File.join(prebuilt_path, "React-VFS.yaml") | ||
| File.write(resolved_vfs_path, resolved_vfs_content) | ||
| rncore_log(" Created VFS overlay at #{resolved_vfs_path}") | ||
|
|
||
| rncore_log("VFS overlay setup complete") | ||
| end | ||
|
|
||
| # Configures the xcconfig files for aggregate (main app) targets to enable VFS overlay for React Native Core. | ||
| # This is needed because the main app target does not go through podspec processing, | ||
| # so it won't get the VFS overlay flags from add_rncore_dependency. | ||
| # `<React/...>` resolves through the vendored React.framework; this adds the search | ||
| # path to the flattened ReactNativeHeaders headers (every other namespace). There is | ||
| # no clang VFS overlay. | ||
| # | ||
| # Parameters: | ||
| # - installer: The CocoaPods installer object | ||
| def self.configure_aggregate_xcconfig(installer) | ||
| return if @@build_from_source | ||
|
|
||
| prebuilt_path = File.join(Pod::Config.instance.project_pods_root, "React-Core-prebuilt") | ||
| vfs_overlay_path = File.join(prebuilt_path, "React-VFS.yaml") | ||
|
|
||
| unless File.exist?(vfs_overlay_path) | ||
| rncore_log("VFS overlay not found at #{vfs_overlay_path}, skipping prebuilt xcconfig configuration", :error) | ||
| exit 1 | ||
| end | ||
|
|
||
| rncore_log("Configuring xcconfig for prebuilt React Native Core...") | ||
|
|
||
| vfs_overlay_flag = " -ivfsoverlay \"#{vfs_overlay_path}\"" | ||
| swift_vfs_overlay_flag = " -Xcc -ivfsoverlay -Xcc \"#{vfs_overlay_path}\"" | ||
| headers_search_path = " \"$(PODS_ROOT)/React-Core-prebuilt/Headers\"" | ||
|
|
||
| # Add flags to aggregate target xcconfigs (these are used by the main app target) | ||
| # Add the header search path to aggregate target xcconfigs (used by the main app target) | ||
| installer.aggregate_targets.each do |aggregate_target| | ||
| aggregate_target.xcconfigs.each do |config_name, config_file| | ||
| add_vfs_overlay_flags(config_file.attributes, vfs_overlay_flag, swift_vfs_overlay_flag) | ||
| add_prebuilt_header_search_paths(config_file.attributes, headers_search_path) | ||
| xcconfig_path = aggregate_target.xcconfig_path(config_name) | ||
| config_file.save_as(xcconfig_path) | ||
| end | ||
| end | ||
|
|
||
| # Add flags to ALL pod targets (for third-party pods that don't call add_rncore_dependency) | ||
| # Add the header search path to ALL pod targets (for third-party pods that don't call add_rncore_dependency) | ||
| installer.pod_targets.each do |pod_target| | ||
| pod_target.build_settings.each do |config_name, build_settings| | ||
| xcconfig_path = pod_target.xcconfig_path(config_name) | ||
| next unless File.exist?(xcconfig_path) | ||
|
|
||
| xcconfig = Xcodeproj::Config.new(xcconfig_path) | ||
|
|
||
| # Check if VFS overlay is already present | ||
| other_cflags = xcconfig.attributes["OTHER_CFLAGS"] || "" | ||
| next if other_cflags.include?("ivfsoverlay") | ||
| # Skip if the prebuilt header search path is already present | ||
| header_search_paths = xcconfig.attributes["HEADER_SEARCH_PATHS"] || "" | ||
| next if header_search_paths.include?("React-Core-prebuilt/Headers") | ||
|
|
||
| add_vfs_overlay_flags(xcconfig.attributes, vfs_overlay_flag, swift_vfs_overlay_flag) | ||
| add_prebuilt_header_search_paths(xcconfig.attributes, headers_search_path) | ||
| xcconfig.save_as(xcconfig_path) | ||
| end | ||
| end | ||
|
|
||
| rncore_log("Prebuilt xcconfig configuration complete") | ||
| end | ||
|
|
||
| # Helper method to add VFS overlay flags to an xcconfig attributes map | ||
| def self.add_vfs_overlay_flags(attributes, vfs_overlay_flag, swift_vfs_overlay_flag) | ||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_CFLAGS", vfs_overlay_flag) | ||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_CPLUSPLUSFLAGS", vfs_overlay_flag) | ||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_SWIFT_FLAGS", swift_vfs_overlay_flag) | ||
| # Helper method to add the prebuilt ReactNativeHeaders header search path to an xcconfig attributes map | ||
| def self.add_prebuilt_header_search_paths(attributes, headers_search_path) | ||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "HEADER_SEARCH_PATHS", headers_search_path) | ||
| # Suppress incomplete umbrella warnings for the prebuilt frameworks (it is expected, as our umbrella headers do not include all headers) | ||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_SWIFT_FLAGS", " -Xcc -Wno-incomplete-umbrella") | ||
| # Activate the ReactNativeHeaders module map so the relocated namespaces | ||
| # (`yoga`, `RCTDeprecation`, `ReactNativeHeaders_react`, ...) are modular — | ||
| # otherwise the React framework's clang explicit-module precompile trips | ||
| # -Wnon-modular-include-in-framework-module on `<yoga/...>` / `<react/...>`. | ||
| # Quoted so a $(PODS_ROOT) containing spaces stays a single clang argument. | ||
| module_map_flag = " \"-fmodule-map-file=$(PODS_ROOT)/React-Core-prebuilt/Headers/module.modulemap\"" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the modulemap template has been deleted. Why are we setting this? From where the modulemap comes from? |
||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_CFLAGS", module_map_flag) | ||
| ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_SWIFT_FLAGS", " -Xcc" + module_map_flag) | ||
| end | ||
| end | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major: This hard-fails install when a tarball lacks ReactNativeHeaders.xcframework (mirrored by a throw in replace-rncore-version.js). Deliberate, but any artifact published before this layout becomes uninstallable with no version-gated fallback — notable on a stable branch. Please confirm the prebuild-ios-core.yml cache key was bumped, otherwise a warm pre-PR cache can skip the new download/extract steps and ship a ReactNativeHeaders-less tarball.