|
11 | 11 |
|
12 | 12 | ### Adds ReactNativeCore-prebuilt as a dependency to the given podspec if we're not |
13 | 13 | ### building ReactNativeCore from source (then this function does nothing). |
| 14 | +### |
| 15 | +### `<React/...>` resolves through the vendored React.framework; every other namespace |
| 16 | +### (`<react/...>`, `<yoga/...>`, `<hermes/...>`, ...) resolves through the flattened |
| 17 | +### ReactNativeHeaders headers that React-Core-prebuilt exposes. The header search path |
| 18 | +### and the ReactNativeHeaders module-map activation are NOT added here: they are applied |
| 19 | +### post-install by configure_aggregate_xcconfig, which covers aggregate, third-party AND |
| 20 | +### these pods from a single injection site. No clang VFS overlay. |
14 | 21 | def add_rncore_dependency(s) |
15 | 22 | if !ReactNativeCoreUtils.build_rncore_from_source() |
16 | | - # Add the dependency |
17 | 23 | s.dependency "React-Core-prebuilt" |
18 | | - |
19 | | - current_pod_target_xcconfig = s.to_hash["pod_target_xcconfig"] || {} |
20 | | - current_pod_target_xcconfig = current_pod_target_xcconfig.to_h unless current_pod_target_xcconfig.is_a?(Hash) |
21 | | - |
22 | | - # Add VFS overlay flags for both Objective-C and Swift |
23 | | - # The VFS overlay file is pre-resolved at pod install time for each platform slice. |
24 | | - # We reference it directly in the xcframework using the React-VFS.yaml file that |
25 | | - # is written to the React-Core-prebuilt folder during setup_vfs_overlay. |
26 | | - # See scripts/ios-prebuild/__docs__/README.md for more details on VFS overlays. |
27 | | - vfs_overlay_flag = "-ivfsoverlay $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml" |
28 | | - current_pod_target_xcconfig["OTHER_CFLAGS"] ||= "$(inherited)" |
29 | | - current_pod_target_xcconfig["OTHER_CFLAGS"] += " #{vfs_overlay_flag}" |
30 | | - current_pod_target_xcconfig["OTHER_CPLUSPLUSFLAGS"] ||= "$(inherited)" |
31 | | - current_pod_target_xcconfig["OTHER_CPLUSPLUSFLAGS"] += " #{vfs_overlay_flag}" |
32 | | - # For Swift, we need to use -Xcc to pass flags to the underlying Clang compiler |
33 | | - # Both the flag and its argument need separate -Xcc prefixes |
34 | | - current_pod_target_xcconfig["OTHER_SWIFT_FLAGS"] ||= "$(inherited)" |
35 | | - current_pod_target_xcconfig["OTHER_SWIFT_FLAGS"] += " -Xcc -ivfsoverlay -Xcc $(PODS_ROOT)/React-Core-prebuilt/React-VFS.yaml" |
36 | | - |
37 | | - s.pod_target_xcconfig = current_pod_target_xcconfig |
38 | 24 | end |
39 | 25 | end |
40 | 26 |
|
@@ -521,96 +507,65 @@ def self.get_nightly_npm_version() |
521 | 507 | return latest_nightly |
522 | 508 | end |
523 | 509 |
|
524 | | - # Processes the VFS overlay file from the React.xcframework to resolve the ${ROOT_PATH} placeholder. |
525 | | - # This method should be called from react_native_post_install after pod install completes. |
| 510 | + # Single post-install injection site for the prebuilt header resolution. Adds the |
| 511 | + # ReactNativeHeaders search path + module-map activation to the aggregate (main app) |
| 512 | + # target AND every pod target — RN core pods, third-party pods alike. (add_rncore_dependency |
| 513 | + # only declares the React-Core-prebuilt dependency; it no longer touches xcconfigs.) |
526 | 514 | # |
527 | | - # The VFS overlay file maps header import paths to their actual locations within the xcframework. |
528 | | - # Since the xcframework contains platform-specific slices, we generate a resolved VFS file for each |
529 | | - # slice and also create a default VFS file that can be used immediately (before script phases run). |
530 | | - def self.process_vfs_overlay() |
531 | | - return if @@build_from_source |
532 | | - |
533 | | - prebuilt_path = File.join(Pod::Config.instance.project_pods_root, "React-Core-prebuilt") |
534 | | - xcframework_path = File.join(prebuilt_path, "React.xcframework") |
535 | | - vfs_template_path = File.join(xcframework_path, "React-VFS-template.yaml") |
536 | | - |
537 | | - unless File.exist?(vfs_template_path) |
538 | | - rncore_log("VFS overlay template not found at #{vfs_template_path}", :error) |
539 | | - exit 1 |
540 | | - end |
541 | | - |
542 | | - rncore_log("Processing VFS overlay file...") |
543 | | - |
544 | | - # Read the template content |
545 | | - vfs_template_content = File.read(vfs_template_path) |
546 | | - |
547 | | - # Write the VFS file - use the top-level xcframework path |
548 | | - # so that ${ROOT_PATH}/Headers points to the xcframework's Headers folder |
549 | | - resolved_vfs_content = vfs_template_content.gsub('${ROOT_PATH}', xcframework_path) |
550 | | - resolved_vfs_path = File.join(prebuilt_path, "React-VFS.yaml") |
551 | | - File.write(resolved_vfs_path, resolved_vfs_content) |
552 | | - rncore_log(" Created VFS overlay at #{resolved_vfs_path}") |
553 | | - |
554 | | - rncore_log("VFS overlay setup complete") |
555 | | - end |
556 | | - |
557 | | - # Configures the xcconfig files for aggregate (main app) targets to enable VFS overlay for React Native Core. |
558 | | - # This is needed because the main app target does not go through podspec processing, |
559 | | - # so it won't get the VFS overlay flags from add_rncore_dependency. |
| 515 | + # `<React/...>` resolves through the vendored React.framework; this adds the search |
| 516 | + # path to the flattened ReactNativeHeaders headers (every other namespace). There is |
| 517 | + # no clang VFS overlay. |
560 | 518 | # |
561 | 519 | # Parameters: |
562 | 520 | # - installer: The CocoaPods installer object |
563 | 521 | def self.configure_aggregate_xcconfig(installer) |
564 | 522 | return if @@build_from_source |
565 | 523 |
|
566 | | - prebuilt_path = File.join(Pod::Config.instance.project_pods_root, "React-Core-prebuilt") |
567 | | - vfs_overlay_path = File.join(prebuilt_path, "React-VFS.yaml") |
568 | | - |
569 | | - unless File.exist?(vfs_overlay_path) |
570 | | - rncore_log("VFS overlay not found at #{vfs_overlay_path}, skipping prebuilt xcconfig configuration", :error) |
571 | | - exit 1 |
572 | | - end |
573 | | - |
574 | 524 | rncore_log("Configuring xcconfig for prebuilt React Native Core...") |
575 | 525 |
|
576 | | - vfs_overlay_flag = " -ivfsoverlay \"#{vfs_overlay_path}\"" |
577 | | - swift_vfs_overlay_flag = " -Xcc -ivfsoverlay -Xcc \"#{vfs_overlay_path}\"" |
| 526 | + headers_search_path = " \"$(PODS_ROOT)/React-Core-prebuilt/Headers\"" |
578 | 527 |
|
579 | | - # Add flags to aggregate target xcconfigs (these are used by the main app target) |
| 528 | + # Add the header search path to aggregate target xcconfigs (used by the main app target) |
580 | 529 | installer.aggregate_targets.each do |aggregate_target| |
581 | 530 | aggregate_target.xcconfigs.each do |config_name, config_file| |
582 | | - add_vfs_overlay_flags(config_file.attributes, vfs_overlay_flag, swift_vfs_overlay_flag) |
| 531 | + add_prebuilt_header_search_paths(config_file.attributes, headers_search_path) |
583 | 532 | xcconfig_path = aggregate_target.xcconfig_path(config_name) |
584 | 533 | config_file.save_as(xcconfig_path) |
585 | 534 | end |
586 | 535 | end |
587 | 536 |
|
588 | | - # Add flags to ALL pod targets (for third-party pods that don't call add_rncore_dependency) |
| 537 | + # Add the header search path to ALL pod targets (for third-party pods that don't call add_rncore_dependency) |
589 | 538 | installer.pod_targets.each do |pod_target| |
590 | 539 | pod_target.build_settings.each do |config_name, build_settings| |
591 | 540 | xcconfig_path = pod_target.xcconfig_path(config_name) |
592 | 541 | next unless File.exist?(xcconfig_path) |
593 | 542 |
|
594 | 543 | xcconfig = Xcodeproj::Config.new(xcconfig_path) |
595 | 544 |
|
596 | | - # Check if VFS overlay is already present |
597 | | - other_cflags = xcconfig.attributes["OTHER_CFLAGS"] || "" |
598 | | - next if other_cflags.include?("ivfsoverlay") |
| 545 | + # Skip if the prebuilt header search path is already present |
| 546 | + header_search_paths = xcconfig.attributes["HEADER_SEARCH_PATHS"] || "" |
| 547 | + next if header_search_paths.include?("React-Core-prebuilt/Headers") |
599 | 548 |
|
600 | | - add_vfs_overlay_flags(xcconfig.attributes, vfs_overlay_flag, swift_vfs_overlay_flag) |
| 549 | + add_prebuilt_header_search_paths(xcconfig.attributes, headers_search_path) |
601 | 550 | xcconfig.save_as(xcconfig_path) |
602 | 551 | end |
603 | 552 | end |
604 | 553 |
|
605 | 554 | rncore_log("Prebuilt xcconfig configuration complete") |
606 | 555 | end |
607 | 556 |
|
608 | | - # Helper method to add VFS overlay flags to an xcconfig attributes map |
609 | | - def self.add_vfs_overlay_flags(attributes, vfs_overlay_flag, swift_vfs_overlay_flag) |
610 | | - ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_CFLAGS", vfs_overlay_flag) |
611 | | - ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_CPLUSPLUSFLAGS", vfs_overlay_flag) |
612 | | - ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_SWIFT_FLAGS", swift_vfs_overlay_flag) |
| 557 | + # Helper method to add the prebuilt ReactNativeHeaders header search path to an xcconfig attributes map |
| 558 | + def self.add_prebuilt_header_search_paths(attributes, headers_search_path) |
| 559 | + ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "HEADER_SEARCH_PATHS", headers_search_path) |
613 | 560 | # Suppress incomplete umbrella warnings for the prebuilt frameworks (it is expected, as our umbrella headers do not include all headers) |
614 | 561 | ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_SWIFT_FLAGS", " -Xcc -Wno-incomplete-umbrella") |
| 562 | + # Activate the ReactNativeHeaders module map so the relocated namespaces |
| 563 | + # (`yoga`, `RCTDeprecation`, `ReactNativeHeaders_react`, ...) are modular — |
| 564 | + # otherwise the React framework's clang explicit-module precompile trips |
| 565 | + # -Wnon-modular-include-in-framework-module on `<yoga/...>` / `<react/...>`. |
| 566 | + # Quoted so a $(PODS_ROOT) containing spaces stays a single clang argument. |
| 567 | + module_map_flag = " \"-fmodule-map-file=$(PODS_ROOT)/React-Core-prebuilt/Headers/module.modulemap\"" |
| 568 | + ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_CFLAGS", module_map_flag) |
| 569 | + ReactNativePodsUtils.add_flag_to_map_with_inheritance(attributes, "OTHER_SWIFT_FLAGS", " -Xcc" + module_map_flag) |
615 | 570 | end |
616 | 571 | end |
0 commit comments