facebook / react-native

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

FBReactNativeSpec/FBReactNativeSpec.h: No such file or directory (in target 'React-Codegen' from project 'Pods') #44731

Open nvacheishvili opened 1 month ago

nvacheishvili commented 1 month ago

Description

I have upgraded to latest react native and I am able to build everything fine locally, while CI keeps throwing this error on build:

FBReactNativeSpec/FBReactNativeSpec.h: No such file or directory (in target 'React-Codegen' from project 'Pods')

ARCHIVE FAILED

The following build commands failed: Copy /Users/runner/Library/Developer/Xcode/DerivedData/MobileApp-fsljxdyguedfjldkjtihcbwatykp/Build/Intermediates.noindex/ArchiveIntermediates/MobileAppDev/BuildProductsPath/Release-iphoneos/React-Codegen/React_Codegen.framework/Headers/FBReactNativeSpec/FBReactNativeSpec.h /Users/runner/work/MobileApp/MobileApp/ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h (in target 'React-Codegen' from project 'Pods') (1 failure) ERROR [2024-05-30 20:10:15.14]: Exit status: 65

Steps to reproduce

N/A

React Native Version

0.74.1

Affected Platforms

Runtime - iOS, Build - MacOS

Areas

Codegen

Output of npx react-native info

System:
  OS: macOS 14.4.1
  CPU: (12) arm64 Apple M2 Max
  Memory: 3.58 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11255304
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/natavacheishvili/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.1
    wanted: ^0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

N/A

Reproducer

N/A

Screenshots and Videos

No response

github-actions[bot] commented 1 month 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.
steadev commented 1 month ago

I got same error sometimes. Reinstall pods worked for me

abhaypithadiya commented 1 month ago

I am facing the same issue. Reinstalling Pods didn't work for me.

cipolleschi commented 1 month ago

Hi all @nvacheishvili @steadev and @abhaypithadiya! In 0.74 there has been a breaking change, for which React-Codegen has been renamed to ReactCodegen to avoid the dance for which static libraries are ok with React-Codegen as a name and frameworks needs React_Codegen (notice the - versus the _).

We also changed a little how we run cocoapods, as Codegen now always runs in both architectures.

The error you linked above, which I paste below, means that your app can't find the FBReactNativeSpec.h file.

FBReactNativeSpec/FBReactNativeSpec.h: No such file or directory (in target 'React-Codegen' from project 'Pods')

** ARCHIVE FAILED **

The following build commands failed:
Copy /Users/runner/Library/Developer/Xcode/DerivedData/MobileApp-fsljxdyguedfjldkjtihcbwatykp/Build/Intermediates.noindex/ArchiveIntermediates/MobileAppDev/BuildProductsPath/Release-iphoneos/React-Codegen/React_Codegen.framework/Headers/FBReactNativeSpec/FBReactNativeSpec.h /Users/runner/work/MobileApp/MobileApp/ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h (in target 'React-Codegen' from project 'Pods')
(1 failure)
ERROR [2024-05-30 20:10:15.14]: Exit status: 65

So, some questions to let you unblock yourselves:

  1. From which library the error come from?
  2. Are you building with the New Architecture or the Old Architecture?
  3. You mentioned that you have the error in CI: are you using a cache, perhaps? Can you try to invalidate it?
  4. Can you create a repro using this template

I just tried to archive a new app created with 0.74 and the archive step worked fine.

nvacheishvili commented 1 month ago

Hey everyone, I resolved this issue in the following way.

I setup the CI with yarn 3.0 (not sure if it did actually have an impact though)

made sure that the runner was on macos-14 building with Xcode 15.4 and ruby 2.7.6

Installed latest cocoapods & updated gemfile in ios using bundle update

Invalidated caches using this script before building:

#!/bin/bash
# Ripped from: https://gist.githubusercontent.com/townofdon/087c7c0bb773adb158f20339c7e13408/raw/53ccb3430cf870c3cdeecead82bc12c3644f2f53/react-native-nuke.sh
# ReactNative script to clean all the things
# usage:
# - add each item below as a separate script in package.json
# - add one final script:
#   - "clean": "yarn clean-node-modules && yarn clean-pods && yarn clean-ios && yarn clean-android && yarn clean-rn-cache"
# - alternatively, copy this shell script and add the following cmd to package.json:
#   - "clean": "./react-native-clean-sh"
#   - you may need to run `sudo chmod 777 ./react-native-clean-sh before this script can run`

echo "                              ____                      "
echo "                      __,-~~/~    \`---.                 "
echo "                    _/_,---(      ,    )                "
echo "                __ /        <    /   )  \___            "
echo "               ====------------------===;;;==           "
echo "                   \/  ~\"~\"~\"~\"~\"~\~\"~)~\",1/            "
echo "                   (_ (   \  (     >    \)              "
echo "                    \_( _ <         >_>'                "
echo "                       ~ \`-i' ::>|--\"                   "
echo "                           I;|.|.|                      "
echo "                          <|i::|i|>                     "
echo "                           |[::|.|                      "
echo "                            ||: |                       "
echo "______________________REACT NATIVE CLEAN ALL________________ "

# clean-node-modules
echo "____________________________________________________________"
echo "About to clean node_modules"
rm -rf node_modules
echo "Done cleaning node_modules"
echo "____________________________________________________________"
# clean-pods
echo "____________________________________________________________"
echo "About to clean pods and reinstall them"
cd ios && rm -rf Pods && cd ..
echo "Done cleaning pods"
echo "____________________________________________________________"
#reinstall node_modules
echo "____________________________________________________________"
echo "About to install node_modules"
npm install --legacy-peer-deps
echo "Done installing node_modules"
echo "____________________________________________________________"
# clean-ios
echo "____________________________________________________________"
echo "About to clean the builds for iOS"
rm -rf ios/build && rm -rf ~/Library/Developer/Xcode/DerivedData && rm -rf ./ios/DerivedData
echo "Done cleaning builds for iOS"
echo "____________________________________________________________"
#reinstall pods
echo "____________________________________________________________"
echo "About to install pods"
cd ios && pod deintegrate && pod install && pod install --repo-update && cd ..
echo "Done installing pods"
echo "____________________________________________________________"
# clean-rn-cache
echo "____________________________________________________________"
echo "About to clean rn cache"
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-*
echo "Done cleaning rn cache"
echo "____________________________________________________________"
abhaypithadiya commented 4 weeks ago

Hey Guys! I am new to App Development so I don't have much knowledge about this.

I installed the latest version using npx react-native@latest init AwesomeProject. Later it asked me if i want to install cocopods to which I responded yes. I am using 1.15.2 version.

After everything was installed. I did npx react-native run-ios in the project directory.

And I got the below error.

Command PhaseScriptExecution failed with a nonzero exit code

warning: Run script build phase '[CP-User] [Hermes] Replace Hermes for the right configuration, if needed' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'hermes-engine' from project 'Pods')
warning: Run script build phase 'Bundle React Native code and images' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'AwesomeProject' from project 'AwesomeProject')
warning: Run script build phase '[CP-User] [RN]Check rncore' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'React-Fabric' from project 'Pods')

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:77BDA196-C250-483C-BD03-8BBAF144CB78, OS:17.4, name:iPhone SE (3rd generation) }
{ platform:iOS Simulator, id:77BDA196-C250-483C-BD03-8BBAF144CB78, OS:17.4, name:iPhone SE (3rd generation) }
** BUILD FAILED **

The following build commands failed:
    PhaseScriptExecution [CP-User]\ Generate\ Specs /.../AwesomeProject-frwntmzqjfbbtpebzntqavmomgxa/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-Codegen.build/Script-46EB2E00012AD0.sh (in target 'React-Codegen' from project 'Pods')
(1 failure)

My Ruby Version is ruby 2.6.10p210 and node Version is v22.1.0

cipolleschi commented 1 week ago

@abhaypithadiya sorry for the late reply. Have you solved the issue? The problem could be that your node is properly setup.

  1. Can you check the content of your .xcode.env.local file?
  2. can you run command -v node?
  3. Does the two match?
abhaypithadiya commented 1 week ago

Hey @cipolleschi! I couldn't solve the issue yet. The content in .xcode.env.local is same as the output which comes when i run command -v node. Both of them match.

papaytl185 commented 1 week ago

I'm also getting this issue with a clean installation and new project. I have no idea how to resolve it!

papaytl185 commented 1 week ago

@abhaypithadiya - I resolved my issue, it ended up being I had the project in a parent folder with a space "Expo Test", changed to "ExpoTest" and everything built!

abhaypithadiya commented 1 week ago

Hey @papaytl185! Thankyou for your reply! But I am not using Expo, and I just copy pasted the code from the documentation so it is just AwesomeProject. So there is no space and it is in the root level not inside any folders.

LydGol90 commented 1 week ago

@cipolleschi I run into this issue when building using static frameworks.

From which library the error come from? React-Codegen

Are you building with the New Architecture or the Old Architecture? New Architecture

I am using RN 0.74.2 - is it expected that ReactCodegen should be installed instead of React-Codegen on this version? Because for me it is always React-Codegen

Hope this helps, thanks!

cipolleschi commented 1 week ago

I am using RN 0.74.2 - is it expected that ReactCodegen should be installed instead of React-Codegen on this version? Because for me it is always React-Codegen

Yeah, you are right. I mixed up versions. We moved from React-Codegen to ReactCodegen in 0.75, not 0.74. I misremembered when I replied above.


I'm trying to repro the issue:

npx react-native@0.74.2 init RN0742 --version 0.74.2 --skip-install
cd RN0742
yarn
cd ios
bundle install
USE_FRAMEWORKS=static RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
cd ..
yarn ios

It builds and run for me.

Screenshot 2024-06-27 at 14 32 45

There should be some other library that is making it fail.

Can you provide a reproducer using this template, please?

abhaypithadiya commented 1 week ago

Hello @cipolleschi! i tried making a reproducer, please check it out: https://github.com/abhaypithadiya/react-native-test. I get the yarn error but i am not using yarn. When I try to build the ios app I still get this error:

 PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/.../Xcode/DerivedData/AwesomeProject-exerqpxetpbwwdampafvvsyirlxo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-Codegen.build/Script-46EB2E00012AD0.sh (in target 'React-Codegen' from project 'Pods')

Hope this helps!

cipolleschi commented 1 week ago

@abhaypithadiya what's the content of your .xcode.env.local? Also, what happen if you build from Xcode instead of with CLI?

abhaypithadiya commented 1 week ago

The content of .xcode.env.local is: export NODE_BINARY=/opt/homebrew/bin/node.

If I build from Xcode I get the same error.

@cipolleschi

chahinramonaghrim commented 5 days ago

I am facing the same issue. I am also on Rn version 0.74 with xcode 15.3.

chahinramonaghrim commented 5 days ago

When building the app using fastlane I get: `e script phase. (in target 'RCT-Folly' from project 'Pods') ARCHIVE FAILED

The following build commands failed: Copy /Users/.../Library/Developer/Xcode/DerivedData/App-gwezcvnfaoafftbtwlztzpvcrteg/Build/Intermediates.noindex/ArchiveIntermediates/App/BuildProductsPath/Release-iphoneos/React-Codegen/React_Codegen.framework/Headers/FBReactNativeSpec/FBReactNativeSpec.h /Users/.../apps/app-app/ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h (in target 'React-Codegen' from project 'Pods') (1 failure) [11:05:50]: Exit status: 65`

zeelgohil commented 2 days ago

Hi everyone,

I was facing the same issue and spent two days thinking it was related to Xcode 15.3, React Native 0.74.3 and React-Codegen. After some investigation, I found the real problem.

If your app is in a directory that contains spaces, this error might occur. For example, my project was inside /React Native/AwesomeProject. I simply changed it to /React-Native/AwesomeProject, and the issue was resolved.

After changing the directory name, follow these steps:

  1. Restart Xcode.
  2. Clean the build folder (Product > Clean Build Folder).
  3. Build your project again.

I hope this helps save someone else time!

@abhaypithadiya see if this solution works for you.