49

Facing this error when I run react-native run-ios after creating the project

Error -

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening BoltAssignment.xcworkspace.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BoltAssignment.xcworkspace -configuration Debug -scheme BoltAssignment -destination id=3E598855-6D4F-4F36-BEE1-8663A1F71787


nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.
Command PhaseScriptExecution failed with a nonzero exit code

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-Glog' 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 'libwebp' 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: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the BoltAssignment editor. (in target 'BoltAssignment' from project 'BoltAssignment')
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')
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: no rule to process file '/Users/harsh_nagalla/dev/BoltAssignment/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/harsh_nagalla/dev/BoltAssignment/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/harsh_nagalla/dev/BoltAssignment/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 'RNFastImage' 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 'SDWebImageWebPCoder' from project 'Pods')

** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/harsh_nagalla/Library/Developer/Xcode/DerivedData/BoltAssignment-cxeqsscopunscndrzxcrfnugkasb/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-1F0D93C9412E4439D9C46216EB143B15.sh
(1 failure)

Steps followed-

  1. yarn install
  2. start metro server
  3. cd ios -> pod install
  4. npx react-native run-ios

Pretty new to react native so I am totally clueless why this is happening. It would be much appreciated if someone can help with this.

If you have faced the same issue and still clueless like me then please share and upvote so it reaches to as many people as possible.

Harsh Nagalla
  • 1,076
  • 3
  • 10
  • 22
  • 4
    Having the same issue. Surprisingly it works fine in my other Mac. I checked pods, node, yarn versions and they are all the same. Opening the .xcworkspace file inside /ios/ folder with Xcode and building from it works fine for me. – Sergio Diez Mar 14 '21 at 20:50
  • 2
    @SergioDiez yes I am in the same situation very bizarre – Harsh Nagalla Mar 14 '21 at 23:59
  • 9
    Having the exact same issue after upgrading to 0.64.0. – Puzz Mar 15 '21 at 03:56
  • 4
    I'm having the same problem, it seems to be an nvm problem, as when I open xcode the app builds fine. – Mush Mar 15 '21 at 11:11
  • 1
    I was having problems building the app and I've realized that I was using `yarn ios` once I used `npx react-native run-ios` the app built successfully. – Mush Mar 16 '21 at 22:28
  • 1
    Had the exact same issue. If I installed node via nvm it produced this error. I had to remove nvm/node and install it via homebrew. Not ideal – sooper Mar 25 '21 at 20:57
  • @sooper Thats kinda weird shouldn't happen because of the way node is installed. – Harsh Nagalla Mar 26 '21 at 05:30

14 Answers14

56

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

Edmundo Rodrigues
  • 7,334
  • 3
  • 27
  • 37
  • 1
    Wow, no idea how you figured this out but this solved it for after weeks of headaches and terrible workarounds. Thank you! – Brady Dowling Nov 01 '21 at 17:19
  • I somehow had `unset PREFIX` in my `.zshrc`. Your solution + removing that line did it for me (after months using the workaround to start RN project from XCode instead) – Andru Nov 13 '21 at 22:37
  • Yeah, so using yarn via homebrew seemed to be my issue, as you mentioned. Removing that and installing via nvm's npm instead sorted it for me. Thanks for this – lee_mcmullen Apr 05 '22 at 21:21
  • even after disabling nvm, the nvm command wouldn't work anymore, though `which node` still returns an nvm path and `node -v` also works, no idea how `node` still works, also checked, no node installed via `brew` (which should also use another path) – Can Rau Apr 22 '22 at 00:37
  • Excellent answer. I'll add that I had to run `nvm use __` again after removing yarn/node that was installed from homebrew before my project recognized node managed by nvm. – projectds May 08 '22 at 04:01
14

The only solution that worked for me currently (RN v0.64.0), till this issue root cause properly identified (seems related to nvm though!) is to go to your /node_modules/react-native/scripts/find-node.sh and set these two lines on top.

You can use patch-package to keep those changes permanent.

unset npm_config_prefix
unset PREFIX
Solly
  • 446
  • 6
  • 14
9

I was facing the same error, and I've just run the command suggested in the error:

$ unset PREFIX.

Afterwards the app was building properly.

Cata Mates
  • 91
  • 2
4

On Mac, using these two steps, I resolved the issue.

  1. I have removed the old ~/.nvm folder. from-comment
  2. Then I have created via command ln -s $(which node) /usr/local/bin/node (from-answer)
Muhammad Maqsood
  • 1,487
  • 17
  • 22
2

Got same error. Tried lots of fixes, but nothing helped. I fixed this problem by creating new user on my mac. IOS app began building again in Xcode. I will make some more research what was the reason. I guess its because of bad development environmet setup.

Villar
  • 33
  • 5
2

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

Kaolin Fire
  • 2,522
  • 28
  • 43
1

I had the same issue, the fastest way for it to work (due to some professional issues) was to completely remove NVM and installing Node through brew (macOS)

Iuji Ujisato
  • 88
  • 1
  • 8
0

React Native 0.64 uses the new codegen part and this does not work correctly (yet) when there are spaces in the path of the project. It's a know bug and will be solved in future version, PR already is made

For now you could use a path without a space in it.

Works

/home/wbroek/projectname/

Does not work

/home/wbroek/project name/
wbroek
  • 43
  • 3
  • But, in the original reporter's error message, there does not appear to be a problem with spaces at all. There may *also* be a problem with spaces, but I don't see how your answer relates to the poster's problem? Or am I missing something? I could be! – Mike Hardy Mar 15 '21 at 19:34
  • Yeah, My path doesn’t have any space and I still get this error, and I think Harsh’s neither as we can see in the log. – Sergio Diez Mar 15 '21 at 20:41
0

It´s a bit of a hack but try this in your podfile: Ref

post_install do |installer|
installer.pods_project.targets.each do |target|
  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
end
0

I have also faced a similar type of issue. I have find solution on react native github repo.

Removing

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion from ~/.bash_profile .

AND

Commenting out all the code from project/node_modules/react-native/scripts/find-node.sh helped to solve this issue.

You can also check original https://github.com/facebook/react-native/issues/31249#issuecomment-811715288

Vishal Dhanotiya
  • 2,285
  • 1
  • 13
  • 31
0

I had this problem while my which node was pointing to /usr/local/bin/node

Solved it by

  1. Installing nvm from curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  2. nvm use 16
  3. cd ios/ Delete podfile.lock and Pods/
  4. pod instal
-1

I had a same problem and could solve it as following steps.

  1. {your project} > ios > Podfile

Change from "false" to "true" at the "hermes_enabled" setting.

:hermes_enabled => true
  1. cd ios && pod install

  2. npx react-native run-ios

-3

I solved this problem using npx react-native run-ios instead of yarn ios.

Maybe can help u .

-5

Yeah, had the same issue, didn't realize it was a new RN version first. Downgraded to 0.63.4 and it works as it should:

yarn upgrade react-native@0.63