Closed ceyhunkeklik closed 2 years ago
I added
unset PREFIX
(probablyunset npm_config_prefix
for OP) to the top ofnode_modules/react-native/scripts/find-node.sh
and that fixes the iOS build. If this works for you, try usingpatch-package
to make this change sticky.
There is no such file I could find. I upgraded react-native from 0.63.4 to 0.64.2 and I am not able to build ios using the react-native run-ios command.
Try
runningnvm unalias default
My System:
- Apple Mac Mini M1 Silicon.
- Mac OS 11.4
- XCode 12.5 (open with Rosetta)
- "react": "17.0.1"
- "react-native": "0.64.2",
- Target Build IOS 14.3
I did the following:
- Updated Node to 16.3.0 in NVM.
- Uninstalled the React Native CLI and Reinstalled
nvm unalias default
- Deleted node_modules folders, pod folder and cleaned build in Xcode
- Deleted everything in /Users/xxxxx/Library/Developer/Xcode/DerivedData
- Installed all packages (npm install)
- Updated pod repo: arch -x86_64 pod repo update
- Installed pod packages: arch -x86_64 pod install
- Then build successfully
(Note: arch -x86_64 only for M1 Silicon)
This saves my day. Thanks.
I am not using nvm for my application. still getting error. However, I am using volta for node
Try
runningnvm unalias default
My System:
- Apple Mac Mini M1 Silicon.
- Mac OS 11.4
- XCode 12.5 (open with Rosetta)
- "react": "17.0.1"
- "react-native": "0.64.2",
- Target Build IOS 14.3
I did the following:
- Updated Node to 16.3.0 in NVM.
- Uninstalled the React Native CLI and Reinstalled
nvm unalias default
- Deleted node_modules folders, pod folder and cleaned build in Xcode
- Deleted everything in /Users/xxxxx/Library/Developer/Xcode/DerivedData
- Installed all packages (npm install)
- Updated pod repo: arch -x86_64 pod repo update
- Installed pod packages: arch -x86_64 pod install
- Then build successfully
(Note: arch -x86_64 only for M1 Silicon)
this worked for me, because I was setting an aliases for my node version earlier
In case anyone wants to try a temporary fix that worked for me: I ended up commenting all lines inside
node_modules/react-native/scripts/find-node.sh
. It seems as if my node environment didn't agree with this script. I could build and run my project on an actual device afterwards without any further issues.Holly.....after two weeks researching, it works ... it works. OMG. Thanks for million. Dude I'm about cryin.
Worked for me as well.
works
thanks, worked for me
adding the package manually fixed it for me.
yarn add --dev react-native-codegen
I have Tried All possible solutions but nothing will work. Finally got work from below
I solved, it turns out this folder is read-only, don't know why but it was a document folder, I move the project to the top level of the document, like document/project, and it works, but place project in document/a/b/c/project it not work, so weird, still looking for an answer.
I added
unset PREFIX
(probablyunset npm_config_prefix
for OP) to the top ofnode_modules/react-native/scripts/find-node.sh
and that fixes the iOS build. If this works for you, try usingpatch-package
to make this change sticky.
This worked for me on my Mac M1, but then it starting showing the same error again. I am currently using React-Native 0.66 alpha release 2. I had to change this line:
set -e
to this:
set +e
This worked for me: https://stackoverflow.com/a/67035460/9360334
Thanks! Running "nvm unalias default" worked for me!
adding the package manually fixed it for me.
yarn add --dev react-native-codegen
i trie this here and works well, thanks
rm -rf ~/Library/Developer/Xcode/DerivedData
+ ctrl+k
in xcode helped
This was a massively frustrating issue for me, I sympathize with everyone who's in the same pit of despair.
I just fixed it for myself, and no one's exact solution quite worked. I think this problem is related to how complicated node installations can be on MacOS (especially M1), so our solutions may all look slightly different. I just posted a lengthy write up on StackOverflow with my process and solution, hopefully it provides some tools to help someone else debug for themselves.
The takeaways:
which node/yarn/npm
is pointing to the correct x86 path.node_modules
with the correct x86 executable.node_modules/react-native/scripts/find-node.sh
to see if you're tripping up on any extraneous node things in your environment.This is for 0.66 & might be a brute force solution
I found that something in the npx pod install
deletes the content of the files, so I just:
yarn remove react-native
yarn add react-native
I have a solution that works but is not permanent if you redo pod install 😔
In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.
When are you going to fix this?
I managed to fix this issue by installing the latest react-native-codegen version:
yarn add --dev react-native-codegen
or:
npm install --save-dev react-native-codegen
I have a solution that works but is not permanent if you redo pod install 😔
In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.
When are you going to fix this?
Thank you! This saved me
Intel 2018 Mac, node 16 installed standalone (no nvm)
npx react-native init RNFBNativeSpecSTILLBorked --template react-native-template-typescript
worked
XCode build and run within XCode works
npm run ios
failed with FBReactNativeSpec errors like the ones above...
edited find-node.sh
to include the unset statements and npm run ios
works.
Rearranging the build phase steps didn't work for me. Literally a fresh install broken, for 3 releases now (I installed .66).
EDIT:
I stated "no nvm installed" - however after closer inspection I discovered the path that is checked for an nvm installation actually exists, but my local which nvm
command returned nothing. I forgot I installed it previously and it looks like the uninstall or some other process did not cleanly remove this hidden directory.
So I removed the hidden directory (rm -rf ~/.nvm
), removed the edits I made to find-node.sh
, and re-ran npm run ios
and the build worked.
Double check that you have the directory present. It may be there after all!
I have a solution that works but is not permanent if you redo pod install 😔
In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.
When are you going to fix this?
This didn't fix, but deleting CP-USER phase did. I took this workaround from here
I recently deleted nvm
from my machine and was getting the error in this issue... what I realized is the script node_modules/react-native/scripts/find-node.sh
points to your .nvm folder. Since I removed nvm
from my machine I no longer needed this folder. So I deleted the folder and I am now able to run my project.
I have a solution that works but is not permanent if you redo pod install 😔
In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.
When are you going to fix this? Worked for me
I have a solution that works but is not permanent if you redo pod install 😔
In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.
When are you going to fix this?
A script inside the Podfile can help you to have this solution permanent.
The script:
if (target.name&.eql?('FBReactNativeSpec')) target.build_phases.each do |build_phase| if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs')) target.build_phases.move(build_phase, 0) end end end
Hope it helps
System:
OS: macOS 12.0.1
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 62.25 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: Not Found
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Watchman: 2021.11.08.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK:
API Levels: 30
Build Tools: 30.0.2
System Images: android-30 | Google APIs Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.3 => 0.66.3
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
nvm unalias default
If you explicitly know what version of node you want to run, there's a way to inject it without patch-package (or, one rabbit-hole I went down, sed). The find-node.sh
script is actually just updating the PATHs that node is looked for, where generate-specs.sh
is actually looking for the node binary...but it allows you to override that with the NODE_BINARY
environment variable.
So you could NODE_BINARY=/usr/local/bin/mynode npx react-native run-ios
@FrancisLeigh Thank you very much. You saved me for a week! I tried various methods and tried again npx, npm, pod, gem, nvm... , but all failed.
I had the same issue today. For me it was a bit of a messy environment that caused it. I recently changed from nvm
to nvs
and had yarn
and node
installed with brew
. I uninstalled yarn
and node
from brew
and removed the ~/.nvm
folder that still existed. In the end I think ~/.nvm
was causing the issue since this is checked in the find-node.sh
script and was found, even though it was not working anymore. I hope this helps anyone.
I have a solution that works but is not permanent if you redo pod install 😔 In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script. When are you going to fix this?
This didn't fix, but deleting CP-USER phase did. I took this workaround from here
This solved it for me.
unset npm_config_prefix
This worked for me.
Here's my react-native info if it helps:
System:
OS: macOS 11.6
CPU: (8) arm64 Apple M1
Memory: 440.63 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 17.3.0 - /opt/homebrew/bin/node
Yarn: 1.22.15 - ~/.nvm/versions/node/v16.11.0/bin/yarn
npm: 8.3.0 - /opt/homebrew/bin/npm
Watchman: 2021.10.18.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.2 => 0.66.2
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Not sure if this helps anyone, but in testing with react-native 0.66.4, after migrating off nvm
, I had to manually run ./node_modules/react-native/scripts/generate-specs.sh
in order for npx react-native run-ios
to succeed, including subsequent builds.
In case anyone wants to try a temporary fix that worked for me: I ended up commenting all lines inside
node_modules/react-native/scripts/find-node.sh
. It seems as if my node environment didn't agree with this script. I could build and run my project on an actual device afterwards without any further issues.
This workaround is working but if there is a solution for this it would be great! I again need to comment if done npm install or added/ removed any package.
For me(I'm Intel mac user), the error occurred after upgrading rn from 0.66 to 0.67, and nvm alias default node
fixed it.
Interesting. Had same issue after upgrading from 0.66 to 0.67. Tried everything, deleting & re-installing pods, re-installing node modules, alias etc. The only think to have worked in my case was changing -e to +e in node_modules/react-native/scripts/find-node.sh
For me(I'm Intel mac user), the error occurred after upgrading rn from 0.66 to 0.67, and
nvm alias default node
fixed it.
This fixed it for me. I'm on an Intel Mac, running MacOS Monterey (v12.1) and Xcode 13.2.1
"rm -rf ~/.nvm" fixed my problem
Updating nvm fixed it for me. https://github.com/nvm-sh/nvm#installing-and-updating
nvm alias default node
@russelh15 Thank you King.
Thank you @russelh15 ! Had been stuck on this for two days now. You're the 🐐
Interesting. Had same issue after upgrading from 0.66 to 0.67. Tried everything, deleting & re-installing pods, re-installing node modules, alias etc. The only think to have worked in my case was changing -e to +e in node_modules/react-native/scripts/find-node.sh
This fixed it for me when upgrading from .63 to .67, I think it might just be an issue to upgrading .67 in general
For me(I'm Intel mac user), the error occurred after upgrading rn from 0.66 to 0.67, and
nvm alias default node
fixed it.This fixed it for me. I'm on an Intel Mac, running MacOS Monterey (v12.1) and Xcode 13.2.1
Ah... i just upgraded to a newer react-native version (0.64 -> 0.67), the problem appeared and this fixed the problem, ty
literally spent 15 hours to fix that problem, which has obviously been around for months. what a shame. I will downgrade to rn 0.63
Seems like 0.67.2 has fix for this
https://github.com/facebook/react-native/releases/tag/v0.67.2
installing nvm fixed for me
Hi! unset npm_config_prefix
works for me!
This is my node_modules/react-native/scripts/find-node.sh
file:
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
# remove global prefix if it's already set
# the running shell process will choose a node binary and a global package directory breaks version managers
unset PREFIX
unset npm_config_prefix
...
I hope it could help someone...
I've tried solutions mentioned and Im still facing the issue
"react": "17.0.2", "react-native": "0.66.4",
I tried adding
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec"
in my podfile and it is still the same too.
..../node_modules/react-native/Libraries/Settings/RCTSettingsManager.mm:10:9: 'FBReactNativeSpec/FBReactNativeSpec.h' file not found
For me(I'm Intel mac user), the error occurred after upgrading rn from 0.66 to 0.67, and
nvm alias default node
fixed it.
@wjaykim you save my life. Cheers
I've tried solutions mentioned and Im still facing the issue
"react": "17.0.2", "react-native": "0.66.4",
I tried adding
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec"
in my podfile and it is still the same too.
..../node_modules/react-native/Libraries/Settings/RCTSettingsManager.mm:10:9: 'FBReactNativeSpec/FBReactNativeSpec.h' file not found
We managed to overcome the issue on our side for now We were using unimodule initially, migrated from unimodule to expo and we are able to compile now.
You can try it if you are on similar setup, here is a document to help with the migration https://github.com/expo/fyi/blob/main/expo-modules-migration.md
For me it failed because I'm not using nvm anymore but there was still a ~/.nvm
directory in my home folder which the find-node.sh
script was targeting. Removing the directory fixed the problem.
I deleted node_modules and re-ran yarn install
then pod install
in .\ios
Using RN 0.67.2 here and what finally worked for me was updating nvm from 0.33 to 0.39.1. The above mentioned fix (https://github.com/facebook/react-native/commit/35bcf934b186e581d100d43e563044300759557f) did not help, it actually caused the breakage. I think the fix assumes everyone is running the latest nvm.
Environment
System: OS: macOS 11.2.3 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 1.27 GB / 16.00 GB Shell: 5.8 - /usr/local/bin/zsh Binaries: Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v12.18.0/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v12.18.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 28, 29 Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.2, 30.0.3 System Images: android-28 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_281 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Things I’ve done to figure out my issue
I used react-native cli to upgrade and the following page to manually changes. https://react-native-community.github.io/upgrade-helper/?from=0.63.4&to=0.64.0
Upgrading version
0.64.0
Description
I've faced the following error when I want to start the IOS app with the "react-native run-ios" command. If I start the debug build from XCode, it is started successfully.
/bin/sh -c /Users/keklikc/Library/Developer/Xcode/DerivedData/DataroidMobile-gmjqxfphavicwkcccsennxqbhvuj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-0565B84ED1A643A94B66851B97B33BAC.sh nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/keklikc/.nvm/versions/node/v12.18.0" Run
unset npm_config_prefix
to unset it. /Users/keklikc/.zshrc: line 83: zstyle: command not found /Users/keklikc/.zshrc: line 84: zstyle: command not found /Users/keklikc/.zshrc: line 85: zstyle: command not found /Users/keklikc/.oh-my-zsh/tools/check_for_upgrade.sh: line 32: syntax error near unexpected token)' /Users/keklikc/.oh-my-zsh/tools/check_for_upgrade.sh: line 32:
() {' /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 21: autoload: command not found /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 39: syntax error near unexpected token(' /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 39:
for plugin ($plugins); do' /Users/keklikc/.zshrc: line 120: autoload: command not found /Users/keklikc/.zshrc: line 129: add-zsh-hook: command not found nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/keklikc/.nvm/versions/node/v12.18.0" Rununset npm_config_prefix
to unset it. Command PhaseScriptExecution failed with a nonzero exit codewarning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-Glog' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'boost-for-react-native' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.4, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-PeerTalk' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'YogaKit' from project 'Pods') warning: no rule to process file '/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/README.md' of type 'net.daringfireball.markdown' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods') warning: no rule to process file '/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt' of type 'text' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods') warning: no rule to process file '/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/benchmarks/README.md' of type 'net.daringfireball.markdown' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-DoubleConversion' from project 'Pods')
BUILD FAILED
The following build commands failed: PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/keklikc/Library/Developer/Xcode/DerivedData/DataroidMobile-gmjqxfphavicwkcccsennxqbhvuj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-0565B84ED1A643A94B66851B97B33BAC.sh (1 failure)
Reproducible demo
Upgrade from 0.63.4 to 0.64.0 then execute react-native run-ios