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

Weird build failure on Xcode after updating to RN 0.66.1 #32432

Closed
gabimoncha opened this issue Oct 18, 2021 · 37 comments
Closed

Weird build failure on Xcode after updating to RN 0.66.1 #32432

gabimoncha opened this issue Oct 18, 2021 · 37 comments
Labels
Type: Upgrade Issue Issues reported from upgrade issue form

Comments

@gabimoncha
Copy link

gabimoncha commented Oct 18, 2021

Description

After updating RN from 0.65.1 to 0.66.1, my iOS builds were failing with the following errors.

Screenshot 2021-10-18 at 17 15 49

I thought one of the libraries I'm using is not compatible with the new version, so I've started a new project from the typescript template and added them one by one.
I turned out that that every time I add a new library with a native change, I get this error message and the only way to bypass it is by cleaning the project and restarting it with the following commands.

rm -rf node_modules ios/build ios/Pods ios/Podfile.lock && yarn cache clean
yarn && cd ios && pod install && cd ../
yarn start --reset-cache

React Native version:

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 353.69 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.9.1 - /opt/homebrew/bin/node
    Yarn: 1.22.11 - /opt/homebrew/bin/yarn
    npm: 7.21.1 - /opt/homebrew/bin/npm
    Watchman: 2021.09.13.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 29, 30, 31
      Build Tools: 29.0.2, 30.0.2, 31.0.0
      System Images: android-31 | ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-31 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 13.0/13A233 - /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.1 => 0.66.1 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

  1. Init a new project (I tested only on Typescript)
  2. Install dependencies, build from Xcode
  3. Install a library any native change so that you can pod install after too (I guarantee it works with the following: react-native-svg + react-native-svg-transformer, react-native-reanimated, react-native-device-info, react-native-dotenv, react-native-file-logger, react-native-safe-area-context)
  4. Restart metro and rebuild from Xcode

Expected Results

App should build successfully as it normally does.

@gabimoncha
Copy link
Author

@lunaleaps I don't think this issue should be closed and I'm not sure if this is an upgrade issue.

@lunaleaps
Copy link
Contributor

Ooops, I didn't know we had that github action -- I had not intended to close it but properly label this to help signal how many issues people have upgrading to a release. Let me fix

@lunaleaps lunaleaps reopened this Oct 21, 2021
@Ppang0405
Copy link

Thanks @gabrielmoncea , your workaround worked for me. But this bug is still annoying.

@carbopilot
Copy link

It's also a problem with a new react-native project .., not just an upgrade.

@carl0shd
Copy link

This is happening to me since React Native 0.66.0, the bug starts from this version.

@facebook facebook deleted a comment from github-actions bot Oct 25, 2021
@lunaleaps
Copy link
Contributor

lunaleaps commented Oct 25, 2021

For the steps to repro, can you share the commands you're running? And maybe a specific native package?

@chengsam
Copy link

I just come across this error and cleaning build folder in Xcode worked for me, but I'm not sure if this works all the time

@Deepacks
Copy link

I am currently facing two different issues:

Using the latest cocoapods version to install the pods (Mac M1 silicon)

The following is the current build error, hope it can be somewhat useful
Screenshot 2021-10-26 at 14 18 37

@carl0shd
Copy link

I just come across this error and cleaning build folder in Xcode worked for me, but I'm not sure if this works all the time

Yep, this works for me too, but the behaviour is the same, this error only appears if I update or install a native library, if I don't do any of that Xcode does not generate an error.

@askndaer1
Copy link

@Deepacks Did u find any solution or suggestions for this bugs ?

@J6ey
Copy link

J6ey commented Oct 28, 2021

@Deepacks I had the same issue on "react-native": "0.66.1"
Changing back to "react-native": "0.65.1" in the package.json, then npm install, pod update, pod install fixed it for me!

Also be sure to comment out __apply_Xcode_12_5_M1_post_install_workaround(installer)

@imsam67
Copy link

imsam67 commented Oct 28, 2021

Is it my imagination or since React Native version 0.64.2 getting a simple app going without any issues right out of the gate has been practically impossible. Add react-native-reanimated version 2 to the mix and I spend hours getting a basic app going.

@Deepacks
Copy link

@J6ey @askndaer1 Hello, i want to share this even though i am in total disbelief that i could get it working because of this.

I had to make sure to place the project (so when i type npx react-native init AppName) in a folder route that must not include any spaces.

This will cause errors ~ cd Desktop/this\ wont\ work && npx react-native init AppName
This will work flawlessly ~ cd Desktop/this-will/ && npx react-native init AppName

Some info about my config:

  • I have installed pod (v 1.11.2) through sudo gem install cocoapods and i also had to install ffi, with the same command, since it is recommended for mac M1 users.
  • Latest node version, through homebrew brew install node
  • Xcode 13.1

Please let me know if your issues can be solved by checking this painfully simple thing.

@pratibhashali
Copy link

HI @facebook, Thank you for wasting 6hr of my day.

@J6ey @askndaer1 Hello, i want to share this even though i am in total disbelief that i could get it working because of this.

I had to make sure to place the project (so when i type npx react-native init AppName) in a folder route that must not include any spaces.

This will cause errors ~ cd Desktop/this\ wont\ work && npx react-native init AppName This will work flawlessly ~ cd Desktop/this-will/ && npx react-native init AppName

Some info about my config:

  • I have installed pod (v 1.11.2) through sudo gem install cocoapods and i also had to install ffi, with the same command, since it is recommended for mac M1 users.
  • Latest node version, through homebrew brew install node
  • Xcode 13.1

Please let me know if your issues can be solved by checking this painfully simple thing.

The above worked.

@den666
Copy link

den666 commented Nov 2, 2021

HI @facebook, Thank you for wasting 6hr of my day.

@J6ey @askndaer1 Hello, i want to share this even though i am in total disbelief that i could get it working because of this.
I had to make sure to place the project (so when i type npx react-native init AppName) in a folder route that must not include any spaces.
This will cause errors ~ cd Desktop/this\ wont\ work && npx react-native init AppName This will work flawlessly ~ cd Desktop/this-will/ && npx react-native init AppName
Some info about my config:

  • I have installed pod (v 1.11.2) through sudo gem install cocoapods and i also had to install ffi, with the same command, since it is recommended for mac M1 users.
  • Latest node version, through homebrew brew install node
  • Xcode 13.1

Please let me know if your issues can be solved by checking this painfully simple thing.

The above worked.

8 hours for me, and it still doesn't work

@Fedeorlandau
Copy link

Same thing happening to me :(

@Dovydastc
Copy link

Dovydastc commented Nov 22, 2021

Upgrading react-native to 0.66.3 fixed an issue for me!

@Fedeorlandau
Copy link

Fedeorlandau commented Nov 22, 2021

Upgrading to the latest RN version fixed it.

@NgocLe1001
Copy link

HI @facebook, Thank you for wasting 6hr of my day.

@J6ey @askndaer1 Hello, i want to share this even though i am in total disbelief that i could get it working because of this.
I had to make sure to place the project (so when i type npx react-native init AppName) in a folder route that must not include any spaces.
This will cause errors ~ cd Desktop/this\ wont\ work && npx react-native init AppName This will work flawlessly ~ cd Desktop/this-will/ && npx react-native init AppName
Some info about my config:

  • I have installed pod (v 1.11.2) through sudo gem install cocoapods and i also had to install ffi, with the same command, since it is recommended for mac M1 users.
  • Latest node version, through homebrew brew install node
  • Xcode 13.1

Please let me know if your issues can be solved by checking this painfully simple thing.

The above worked.

8 hours for me, and it still doesn't work

not work for me. any idea?

@chengsam
Copy link

chengsam commented Dec 9, 2021

HI @facebook, Thank you for wasting 6hr of my day.

@J6ey @askndaer1 Hello, i want to share this even though i am in total disbelief that i could get it working because of this.
I had to make sure to place the project (so when i type npx react-native init AppName) in a folder route that must not include any spaces.
This will cause errors ~ cd Desktop/this\ wont\ work && npx react-native init AppName This will work flawlessly ~ cd Desktop/this-will/ && npx react-native init AppName
Some info about my config:

  • I have installed pod (v 1.11.2) through sudo gem install cocoapods and i also had to install ffi, with the same command, since it is recommended for mac M1 users.
  • Latest node version, through homebrew brew install node
  • Xcode 13.1

Please let me know if your issues can be solved by checking this painfully simple thing.

The above worked.

8 hours for me, and it still doesn't work

not work for me. any idea?

As mentioned by others, upgrading your react native version should work.

@adnansudozai
Copy link

@Deepacks I had the same issue on "react-native": "0.66.1" Changing back to "react-native": "0.65.1" in the package.json, then npm install, pod update, pod install fixed it for me!

Also be sure to comment out __apply_Xcode_12_5_M1_post_install_workaround(installer)

Thanks its work for me

@WNemencha
Copy link

WNemencha commented Jul 5, 2022

Got this one also while updating from Expo 44 (RN 0.63.4) to Expo 45 (RN 0.68.2) and I cannot figure out how to resolve it, has anyone ever found a proper solution to this?


EDIT: Needed to enable the new architecture while installing pods with:

$ RCT_NEW_ARCH_ENABLED=1 pod install

EDIT2: After hours of researching i'm back to this issue, because react-native-reanimated does not works with new architecture + react-native 0.68.2... I'm starting to loose hope, back to the old pod install except that with new c++ code it does not build anymore.

EDIT3: It seems somehow that the files ios/build/generated/FBReactNativeSpec* are empty, could the issue be linked to that as it says it Cannot find protocol declaration for 'NativeVibrationSpec' ?

EDIT4: I've fixed that by properly setting the nvm default alias to node@16.14.0 on my machine, then the build phase was able to generate the Spec files properly.


image

Same happens when running the app from command-line (i.e; with npx expo run:ios)

image

@alerighi
Copy link

I have the same issue on a Mac M1. Is this issue caused by the ARM architecture? Is there a workaround for it, or do I need to downgrade to Expo 44?

@WNemencha
Copy link

WNemencha commented Jul 13, 2022

@alerighi I'm on an Intel mac so not linked to M1

@alerighi
Copy link

I've tried on a Intel MAC and the build is successful. To give some context, I'm using fastlane to build the application (the M1 Mac is used for the CI process). I really have no idea on how to solve the issue, I've tried everything.

@WNemencha
Copy link

@alerighi The actual issue seems to be that the Phase Script does not generate Spec files (used by the new arch i feel) because it does not find node, and thus cannot run the generate spec script (as I understand it).

What worked for me was to check that the default version in my nvm setup was properly set. You can do so like this:

# Check if it's set (should said unset or smth like that)
$ nvm alias default
# If unset, then set it!
$ nvm alias default v16.14.0

Of course if you don't use nvm, then i don't know 😅

@alerighi
Copy link

It seem to generate some files but are in a directory out/ inside the directory where the file would normally be placed.

I have node installed with brew rather than with nvm. Can it be a problem since I'm using a arm version of node?

@alerighi
Copy link

Finaly found the issue! I traced it down to a difference in how cp command from GNU Coreutils and the BSD one in MacOS works. The cp -R command is used in the last phase of the script that script_phase.sh, that copies the files from a temporary directory (out/) to the final destination launched this command:

cp -R "build/generated/ios/out/" "build/generated/ios"

GNU Coreutils cp interpret this as copy the directory build/generated/ios/out/ to build/generated/ios/out, which are the same file, and thus the command fails, while BSD interpret this as copy build/generated/ios/out/* to build/generated/ios/ (by the way, it's not clear to me what behavior is POSIX compliant, it seem to me the second one).

By removing the GNU Coreutils from the PATH it works as expected (I did have them in PATH since I mainly use Linux and I'm used to them). A mystery solved.

@zumby
Copy link

zumby commented Jul 28, 2022

hell...
this is really the case.
removing GNU Coreutils from PATH (switch back to macOS native cli utils) - resolves the issue.
Thank you so much @alerighi !

@suyashvash
Copy link

@Deepacks I had the same issue on "react-native": "0.66.1" Changing back to "react-native": "0.65.1" in the package.json, then npm install, pod update, pod install fixed it for me!

Also be sure to comment out __apply_Xcode_12_5_M1_post_install_workaround(installer)

Dude, you saved my day. Literally worked just by doing these changes. I was struggling with it for days. Thanks, buddy.

@rrameshbtech
Copy link

Tried most. But none of the solution works. Its brand new solution after npx react-native init. not sure how to continue.

@Joshuapwilley
Copy link

Finaly found the issue! I traced it down to a difference in how cp command from GNU Coreutils and the BSD one in MacOS works. The cp -R command is used in the last phase of the script that script_phase.sh, that copies the files from a temporary directory (out/) to the final destination launched this command:

cp -R "build/generated/ios/out/" "build/generated/ios"

GNU Coreutils cp interpret this as copy the directory build/generated/ios/out/ to build/generated/ios/out, which are the same file, and thus the command fails, while BSD interpret this as copy build/generated/ios/out/* to build/generated/ios/ (by the way, it's not clear to me what behavior is POSIX compliant, it seem to me the second one).

By removing the GNU Coreutils from the PATH it works as expected (I did have them in PATH since I mainly use Linux and I'm used to them). A mystery solved.

For anyone else experiencing this issue, another solution is to use patch-package to patch this file:
node_modules/react-native/scripts/react_native_pods_utils/script_phases.sh

Change this line:
cp -R "$TEMP_OUTPUT_DIR/" "$RCT_SCRIPT_OUTPUT_DIR" || exit 1

To this:
cp -R "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR/." || exit 1

This change should make this work with GNU and BSD.

@kelset
Copy link
Contributor

kelset commented Sep 12, 2022

@Joshuapwilley anything preventing the change you are suggesting to be submitted as a PR? Is there one out already?

@acshi
Copy link

acshi commented Sep 22, 2022

For anyone else reading this. The only thing I have had success with was using:
RCT_NEW_ARCH_ENABLED=1 pod install or rather RCT_NEW_ARCH_ENABLED=1 arch -x86_64 pod install on my M1 Mac, as the cp -R "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR/." || exit 1 change did nothing for me.

shreeve added a commit to shreeve/react-native that referenced this issue Nov 17, 2022
See the issue at facebook#32432 (comment)

This fixes a bizarre issue when using the GNU coreutils tools. There are very minor changes in the standard command-line tools on macOS and the GNU coreutils. The `cp` command has slightly different semantics across these operating systems, so this commit normalizes those differences and allows GNU coreutils to be used or the system native version of `cp`.
github-actions bot pushed a commit to shreeve/react-native that referenced this issue Nov 25, 2022
See the issue at facebook#32432 (comment)

This fixes a bizarre issue when using the GNU coreutils tools. There are very minor changes in the standard command-line tools on macOS and the GNU coreutils. The `cp` command has slightly different semantics across these operating systems, so this commit normalizes those differences and allows GNU coreutils to be used or the system native version of `cp`.
@shreeve
Copy link
Contributor

shreeve commented Nov 25, 2022

@Joshuapwilley - #35382 has this merged.

    # Copy all output to output_dir
-   cp -R "$TEMP_OUTPUT_DIR/" "$RCT_SCRIPT_OUTPUT_DIR" || exit 1
+   cp -R "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1

This one byte commit (the "/." wasn't needed on the destination directory above) fixes the issues for our team (which is using the GNU coreutils version of the cp command).

Thanks for doing the hard work of finding this sucker.

@shreeve
Copy link
Contributor

shreeve commented Nov 28, 2022

I made a little visual to show the difference in the cp command based on BSD (default on macOS) and GNU (Linux, likely Windows, and also used commonly on macOS).

#35382 (comment)

kelset pushed a commit that referenced this issue Nov 30, 2022
Summary:
See the issue at #32432 (comment)

This fixes a bizarre issue when using the GNU coreutils tools. There are very minor differences in the standard command-line tools on macOS and the GNU coreutils. The `cp` command has slightly different semantics across these operating systems, so this commit normalizes those differences and allows GNU coreutils to be used or the system native version of `cp`.

Fixes #32432

## Changelog

[General] [Fixed] - Allow GNU coreutils to be used to build projects

Pull Request resolved: #35382

Test Plan: This change allows the use of the system or GNU coreutils verson of `cp`.

Reviewed By: cipolleschi

Differential Revision: D41532472

Pulled By: cortinico

fbshipit-source-id: f0fe5274d3828bf6099deceee797a82a6adfdcab
@aramyesildeniz
Copy link

For me it was also the wrong cp command.
Only the BSD worked.

You can also change cp version Instead of changing script_phases.sh.

First check cp version with which cp:

/usr/local/bin/cp --> thats GNU

The BSD version is in
/bin/cp

Change with:

export PATH=/bin:$PATH

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this issue May 22, 2023
…ok#35382)

Summary:
See the issue at facebook#32432 (comment)

This fixes a bizarre issue when using the GNU coreutils tools. There are very minor differences in the standard command-line tools on macOS and the GNU coreutils. The `cp` command has slightly different semantics across these operating systems, so this commit normalizes those differences and allows GNU coreutils to be used or the system native version of `cp`.

Fixes facebook#32432

## Changelog

[General] [Fixed] - Allow GNU coreutils to be used to build projects

Pull Request resolved: facebook#35382

Test Plan: This change allows the use of the system or GNU coreutils verson of `cp`.

Reviewed By: cipolleschi

Differential Revision: D41532472

Pulled By: cortinico

fbshipit-source-id: f0fe5274d3828bf6099deceee797a82a6adfdcab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Upgrade Issue Issues reported from upgrade issue form
Projects
None yet
Development

No branches or pull requests