Skip to content
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

Fix duplicate entries in HEADER_SEARCH_PATHS when running react_native_post_install script #46262

Closed

Conversation

dirkpostma
Copy link
Contributor

@dirkpostma dirkpostma commented Aug 29, 2024

Summary:

In a react native project where USE_FRAMEWORKS is not nil, every time when running pod install, duplicate lines are added to HEADER_SEARCH_PATHS section of project.pbxproj:

" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",

Note: a popular library that needs use_frameworks is react-native-firebase.
See https://rnfirebase.io/#altering-cocoapods-to-use-frameworks

Analyse

  • react_native_post_install calls ReactNativePodsUtils.update_search_paths(installer)
  • when ENV['USE_FRAMEWORKS'] != nil then update_search_paths calls add_search_path_if_not_included
  • add_search_path_if_not_included checks if "#{new_search_path}" is already there
  • if not found it adds " #{new_search_path}" with an extra space
  • next time, it can't find "#{new_search_path}" because of the extra space, and adds " #{new_search_path}" again

Changelog:

[IOS] [FIXED] - react_native_post_install script no longer adds duplicate entries to HEADER_SEARCH_PATHS

Test Plan:

  • create a react native project
  • add use_frameworks! :linkage => :static to ios/Podfile (just before use_react_native)
  • run pod install
  • assert no duplicate lines are added to HEADER_SEARCH_PATHS of file project.pbxproj

@facebook-github-bot
Copy link
Contributor

Hi @dirkpostma!

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!

@facebook-github-bot
Copy link
Contributor

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-bot facebook-github-bot added 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. labels Aug 29, 2024
@dirkpostma dirkpostma changed the title Remove extra space character when adding header search paths Fix duplicate entries in HEADER_SEARCH_PATHS when running react_native_post_install script Aug 29, 2024
@facebook-github-bot
Copy link
Contributor

@shwanton has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cipolleschi
Copy link
Contributor

/rebase - this comment automatically rebase on top of main

@github-actions github-actions bot force-pushed the fix_update_search_paths_script branch from ef2f1fd to 1d6983c Compare August 30, 2024 13:39
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.

Thanks for doing this! It's amazing that you added also the tests!
That's the best solution: I didn't want to suggest it in advance as it was quite a bit of work that I would have put on your shoulders, but I'm glad you did it!

@facebook-github-bot
Copy link
Contributor

@shwanton has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@dirkpostma
Copy link
Contributor Author

dirkpostma commented Sep 5, 2024

@cipolleschi I noticed a linter build step failed on the meta internal CI servers. Unfortunately I can’t view the logs there and I don’t know the linting rules. I did make some changes with regard to whitespacing in the last commit, but that’s a bit of a guess. If this doesn’t fix it, can you do it? Thanks!

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 7, 2024
@facebook-github-bot
Copy link
Contributor

@shwanton merged this pull request in d687d38.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @dirkpostma in d687d38

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. 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