Skip to content

Conversation

@chrfalch
Copy link
Collaborator

@chrfalch chrfalch commented Dec 10, 2025

Summary:

Replace the regex-based approach for parsing podspec files with a declarative configuration system for header file collection:

Add headers-config.js with explicit podspec configurations defining header patterns, directories, and subspecs

  • Add vfs.js to generate VFS overlay YAML files for Clang virtual file system support
  • Refactor headers.js to use the new configuration-based approach with support for nested subspecs and path preservation
  • Update xcframework.js to handle the new header mapping structure with source/target paths
  • This provides more reliable and maintainable header file collection for XCFramework builds by avoiding fragile regex parsing of Ruby podspec files.

Prev PR: #54840
Next PR: #54842

Changelog:

[IOS] [FIXED] - refactored header files generator for prebuilt React framework

Test Plan:

Run RNTester with prebuilt

@chrfalch chrfalch requested a review from cipolleschi December 10, 2025 14:15
@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 Dec 10, 2025
@facebook-github-bot facebook-github-bot added 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. labels Dec 10, 2025
@github-actions
Copy link

Job Summary for Gradle

Test All :: run_fantom_tests
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
react-native-github :private:react-native-fantom:buildFantomTester 9.0.0 Build Scan not published

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment below. There are also some warnings on redeclared variables and variables declared but not used, so perhaps this PR requires a bit of work yet?

*/

// Remember that our GLOB library doesn't like {h} in its patterns, so we use **/*.h instead of **/*.{h}
const PodSpecConfigurations /*: {[key: string]: PodSpecConfiguration} */ = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really a fan that we have to maintain this manually, to be fair...
Can't we have a script that generates this file by globbing all the podspecs we have in the framework?
I also know that the pod command has an option to output the json representation of a .podspec file. Perhaps we can use that instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote it to read podspec_sources from all podspec files and exclude files - and then for the header-configs.js to contain a list of exception configuration for those pod specs that contains programmatically generated lists of exclude files, sources or specs.

Outputs exactly the same list of header files as the first iteration.

@chrfalch chrfalch requested a review from cipolleschi December 10, 2025 19:41
@github-actions
Copy link

Job Summary for Gradle

Test All :: run_fantom_tests
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
react-native-github :private:react-native-fantom:buildFantomTester 9.0.0 Build Scan not published

@cipolleschi cipolleschi changed the base branch from main to chrfalch/react-precompile-change-to-angled-include-in-umbrella December 16, 2025 15:27
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm not super excited about is that we are still depending on the podspec structure to decide which headers we need. That's ok for now, but as soon as we drop the Cocoapods infra, this will have to be rewritten again.

preservePaths?: Array<string>,
} | {disabled: true}>;
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps let's add a comment here to explain why this is needed and which podspec needs custom mapping.

Something like:

/*
 Some pods have special configuration for where the Headers needs to be located or for how they are composed.
The following contains a representation of those exceptions.
  * React-jsi: needs the headers in <folder>
  * React-Fabric: it is composed by multiple subspecs and they require headers in specific folders:
    * animated: react/renderer/animated
    * ...
*/

.flat();

// Use the first podspec spec name as the podspec name (this is the root spec in the podspec file)
const podSpecName = podSpecsWithHeaderFiles[podspec][0].specName.replace(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you look into these warning too? @chrfalch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These warnings are fixed in the next PR in the stack. Sorry!

@chrfalch chrfalch force-pushed the chrfalch/react-precompile-change-to-angled-include-in-umbrella branch 3 times, most recently from a91c7bb to 0b0199e Compare January 5, 2026 13:38
A small cleanup to make the directory structure of the header file template when building xcframeworks.

Umbrella and module map templates are now moved into templates folder.
To make the later VFS overlays work, our React umbrella header needs to use angled import syntax instead of quoted".

This is so that the compiler will look up by module and not only by path.
Replace the regex-based approach for parsing podspec files with a declarative configuration system for header file collection:

Add headers-config.js with explicit podspec configurations defining header patterns, directories, and subspecs

- Add vfs.js to generate VFS overlay YAML files for Clang virtual file system support
- Refactor headers.js to use the new configuration-based approach with support for nested subspecs and path preservation
- Update xcframework.js to handle the new header mapping structure with source/target paths
- This provides more reliable and maintainable header file collection for XCFramework builds by avoiding fragile regex parsing of Ruby podspec files.
Now it reads from podspec files, except for some special cases that we have in the config file.

Updated RCTSwiftUIWrapper.podspec to use podspec_sources (which we use to detect source)

I tested this against the header files I got with the previous iteration, and also with the ones installed by Cocoapods.
@chrfalch chrfalch force-pushed the chrfalch/react-precompile-refactor-header-file-generator branch from d0c3305 to b1fdfaf Compare January 5, 2026 13:43
@chrfalch chrfalch changed the base branch from chrfalch/react-precompile-change-to-angled-include-in-umbrella to main January 5, 2026 13:44
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.

4 participants