facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.52k stars 24.27k forks source link

HEADER_SEARCH_PATHS concatenation issue #41721

Open hamidhadi opened 10 months ago

hamidhadi commented 10 months ago

New Version

0.72.6

Old Version

0.70.5

Build Target(s)

iOS simulator

Output of react-native info

System: OS: macOS 14.1.1 CPU: (10) arm64 Apple M1 Pro Memory: 812.52 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 16.14.0 path: ~/.nvm/versions/node/v16.14.0/bin/node Yarn: version: 1.22.21 path: ../node_modules/.bin/yarn npm: version: 8.3.1 path: ~/.nvm/versions/node/v16.14.0/bin/npm Watchman: Not Found Managers: CocoaPods: version: 1.14.3 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms:

Issue and Reproduction Steps

After upgrading to the new version, we also upgraded our RNFirebase module which requires Cocoapods to use framework. As a result of these changes, whenever I run pod install, I see new changes in my Xcode HEADER_SEARCH_PATHS. It seems that you are concatenating the search paths with the previous ones. Probably in this script.

image

github-actions[bot] commented 10 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
cipolleschi commented 10 months ago

Hi @hamidhadi, thanks for the report. I'll look into it. What is the pod that is getting multiple HEADER_SEARCH_PATHS?

The link you added refers to a function called get_react_codegen_spec that we use internally to create the React-Codegen podspec on the flight. So it is regenerated at every pod install, and therefore the search_path should not concatenate. I suspect for the issue to happen in some other podspec.

cipolleschi commented 10 months ago

PSA: I'll be on PTO from tomorrow until the 12th of December.

annuh commented 9 months ago

I'm experiencing the same issue (most probably after updating to React Native 0.73.0, but we've also bumped other dependencies).

                HEADER_SEARCH_PATHS = (
                    "$(inherited)",
                    "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
                    "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
                    "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
                    "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
                    "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
                    " ${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",
+                   " ${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",
                );

This concatenation happens in every configuration (Debug, Release) after running pod install.

It seems that after removing the Pods_Kaartje2go.framework build phase (under Link Binary With Libraries), this concatenation does not happen.

cipolleschi commented 9 months ago

@annuh Could you share on which target it is happening? Could any of you prepare a repro using https://github.com/react-native-community/reproducer-react-native? Otherwise it is really hard for me to help you out, because I am not able to reproduce this behavior locally.

annuh commented 9 months ago

@cipolleschi I've created a reproducer here: https://github.com/annuh/reproducer-react-native.

I believe it's related to an old/correct installation of RN Firebase, since I fixed the issue by reinstalling the Firebase library.

The HEADER_SEARCH_PATHS in my original ./ios/AwesomeProject.xcodeproj/project.pbxproj contained this:

HEADER_SEARCH_PATHS = (
   "$(inherited)",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
   "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
   "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
);

This happened after a pod install:

HEADER_SEARCH_PATHS = (
   "$(inherited)",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
   "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
   "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
+  " ${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",
);

However, when I reinstalled RN Firebase completely in a new project, the HEADER_SEARCH_PATHS contained this:

HEADER_SEARCH_PATHS = (
   "$(inherited)",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", #
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
   "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
   "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", #
   "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
   "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", #
   "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",

So a pod install added all the 'missing'(?) folders, which is probably correct 🙂
The problem is that it adds these lines with a trailing ` (whitespace), so these folders are added after everypod install`.

dylancom commented 8 months ago

I experience the concatenation since upgrading to react-native 0.73.2. After every pod install the following lines are added to my project:

" ${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",
cipolleschi commented 8 months ago

Are these repeated multiple times? Because it is expected for you to have these 3 new lines.

If they are repeated, try to run: bundle exec pod deintegrate to cleanup the Pod structure and then rerun: bundle eexec pod install to reinstall it.

dylancom commented 8 months ago

Yes there are repeated. It seems that pod deintegrate fixed it! Thanks!

d-moreira commented 8 months ago

Had the same issue after updating react-native from v0.72.6 to v.073.2. The only thing that prevented subsequent install pods steps from adding the same 3 lines again was to manually edit the project.pbxproj file and remove the empty spaces added at the beginning of each of the 3 lines.

zcmgyu commented 8 months ago

Despite upgrading react-native-firebase as per @annuh’s suggestion, I still encountered the issue of duplicated concatenation and white space prefix at HEADER_SEARCH_PATHS.

My current workaround:

Bardiamist commented 8 months ago

I noticed that these lines start with spaces. I removed spaces and it helped. 🎉

mhyassin commented 7 months ago

Removing the spaces is definitely going to fix it, it is better though to replace the HEADER_SEARCH_PATHS with

HEADER_SEARCH_PATHS = (
"$(inherited)",
);

then run pod install in the ios directory, this will generate the correct paths again, for some reason pod deintegrate doesn't do this

ChikyChan commented 4 months ago

I'm guessing that maybe this commits to make this behaviour happens: https://github.com/facebook/react-native/commit/fa6f170658723acffcac0102386c8efcd37f121e#diff-2bd8393b331d124e068c72072334b0d49cc9aea43828f768b36c5dc25576b4c7

I'm using use_frameworks! :linkage => :static for my build target in my Podfile, and I checked the added lines in my pbxproj file after run pod install and find out this is the most possible commit to make the HEADER_SEARCH_PATHS concatenated.

In line 281, the script will generate the header search paths then use self.add_search_path_if_not_included to concat our HEADER_SEARCH_PATHS, and in the definition of self.add_search_path_if_not_included in utils.rb, I see it will add a whitespace prefix if the search path not included. image

As the function to check the search path without the whitespace prefix, so the checking will be always true in this case, this will let the script will add the 'not exists' search path into our pbxproj file each pod install run time.

pke commented 1 month ago

Removing the spaces is definitely going to fix it, it is better though to replace the HEADER_SEARCH_PATHS with

HEADER_SEARCH_PATHS = (
"$(inherited)",
);

then run pod install in the ios directory, this will generate the correct paths again, for some reason pod deintegrate doesn't do this

@mhyassin This doesn't change a thing here. pod install will re-add the paths.

mhyassin commented 1 month ago

@pke, yes but this time it would not contain duplicates or white-spaces, that's just a solution for not editing the pbxproj file manually

dirkpostma commented 1 month ago

I created a PR to fix this issue, before I saw this issue. It's indeed caused by an extra space when the scripts adds entries to HEADER_SEARCH_PATHS, see https://github.com/facebook/react-native/pull/46262