facebook / react-native

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

Command PhaseScriptExecution failed with a nonzero exit code - Error when Archive on Xcode 14.3 #36762

Open leofolive opened 1 year ago

leofolive commented 1 year ago

Description

Hi Guys, I'm trying to perform an archive using 0.71.5 but I'm getting an error.

The error occurs in Build phase "[CP] Embed Pods Frameworks", when he runs the script with:

"${PODS_ROOT}/Target Support Files/Pods-MyApp/Pods-MyApp-frameworks.sh"

React Native Version

0.71.5

Output of npx react-native info

System: OS: macOS 13.3 CPU: (8) arm64 Apple M1 Memory: 79.22 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm Watchman: 2022.11.14.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/leonardo.felipe/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: API Levels: 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0 System Images: android-32 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a Android NDK: 22.1.7171670 IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: 11.0.14.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.5 => 0.71.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Snack, code example, screenshot, or link to a repository

Investigating the problem I noticed that the problem occurs in the "Symlinked..." of the script Pods-MyApp-frameworks.sh

  if [ -L "${source}" ]; then
    echo "Symlinked..."
    source="$(readlink "${source}")"
  fi

Workaround is to update all the generated ...-frameworks.sh files to add the -f flag to the call to readlink. In other words, replace source="$(readlink "${source}")" with source="$(readlink -f "${source}")"

The Workaround above was suggested for the issue below and has now been merged into the cocoapods repository. I believe we will need an RC with this FIX pointing to the new version of cocoapods as soon as it is released.

https://github.com/CocoaPods/CocoaPods/issues/11808 https://github.com/CocoaPods/CocoaPods/pull/11828

netvalue-emursali commented 1 year ago

Having the same issue. Apple M2 Pro, Xcode 14.3.

JacobFJ commented 1 year ago

+1

Daha62 commented 1 year ago

+1

milind-betaflux commented 1 year ago

Facing the same issue.

rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/97f6331a-ba75-11ed-a4bc-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]

Command PhaseScriptExecution failed with a nonzero exit code

UPDATE adding '-f' on the highlighted line in this file resolved my issue. You can try this

Screenshot 2023-04-13 at 9 56 22 AM
kelset commented 1 year ago

duplicate of https://github.com/facebook/react-native/issues/36739

leofolive commented 1 year ago

@kelset I believe that although this question deals with an error in the same build phase, it seems to me that it pertains to different matters.

The patch reported in the problem you cited, does not solve my problem.

I had a very strange issue where the pods frameworks script would fail to copy the framework files when archiving a build (building worked fine).

johnsoncwb commented 1 year ago

@kelset can you check again this error? it looks different for me from #36739

kelset commented 1 year ago

re opening - but it looks like it's not a react-native problem, but cocoapods, so not really anything we can do about it https://github.com/CocoaPods/CocoaPods/pull/11828 --- I'll pass it along

StefanWallin commented 1 year ago

While trying to upgrade step by step from 0.69.1 to 0.71.5 step by step I have not gotten fastlane to build the latest week. iOS simulator runs fine.

I have applied the target deployment version patch and set my Gemfile for

gem 'cocoapods', git: 'https://github.com/CocoaPods/CocoaPods.git', branch: 'master'

which resolves to https://github.com/CocoaPods/CocoaPods/commit/3ac99beed81d11a830bdce2fac761a49bae47e83.

Given these changes a clean out and pod-reinstall I'm still seeing symlink issues after running this darling command:

rm -rf ~/Library/Developer/Xcode/DerivedData/ && pod cache clean --all && rm -rf build && cd .. && rm -rf node_modules && npm i && cd ios && pod install; bundle exec fastlane beta config:staging

from the ios folder.

The log output from fastlane is saying:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/IntermediateBuildFilesPath/app_name.build/Release-iphoneos/app_name.build/Script-01409BA429EB16AADA33A048.sh (in target 'app_name' from project 'app_name')
    cd /Users/stefanwallin/iteam/app_name_app/app/ios
    /bin/sh -c /Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/IntermediateBuildFilesPath/app_name.build/Release-iphoneos/app_name.build/Script-01409BA429EB16AADA33A048.sh
mkdir -p /Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/BuildProductsPath/Release-iphoneos/app_name.app/Frameworks
Symlinked...
rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/DoubleConversion.framework" "/Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/InstallationBuildProductsLocation/Applications/app_name.app/Frameworks"
building file list ... rsync: link_stat "/Users/stefanwallin/iteam/app_name_app/app/ios/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/DoubleConversion.framework" failed: No such file or directory (2)

Which to me clearly indicates a still present symlink issue. Are we still convinced this is a cocoapods-issue or how RN uses cocoapods or the script? I'm happy to move this issue to the cocoapods-repo but it seems to me it might be due to some internal use in DoubleConversion?

Also, cocoapods does not accept issues with RN/Flutter, as per their new issue template. I am not sure where to start to make this a reproducible issue without RN.

WARNING: Please do not file issues for CocoaPods with projects 
that use React Native or Flutter. Please remove React Native or Flutter
in your sample app in order to properly demonstrate an issue with CocoaPods itself.

The integration between CocoaPods and React Native or Flutter 
makes it very difficult for us to diagnose and fix issues.

Issues with React Native or Flutter will be closed.
salamohamad commented 1 year ago

Same issue using flutter

OrbitalTech commented 1 year ago

I am also facing the same issue, after updating to the lates XCode V14.3

cegonzal1991 commented 1 year ago

Also having the same issue when i try to archive my App. After updated Xcode to V14.3

dacowles commented 1 year ago

Yes, same issue here after upgrading to Xcode 14.3. Cocoapods is broken in this release. Anyone been able to resolve?

alroniks commented 1 year ago

@dacowles I've done as described here and it solved my issue

maks1mp commented 1 year ago

Same issue. React Native 0.65. The following build commands failed: CompileC /{path}/mobile/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Yoga' from project 'Pods') (1 failure)

ianmgithua commented 1 year ago

check for spaces as you are naming the project folders. Use space alternatives.

rovin01 commented 1 year ago

This help me to fix the issue. https://developer.apple.com/forums/thread/725230 Please have a look, may be this will help..!

danidaryaweesh commented 1 year ago

For everyone still having this issue, I recommend to follow the instructions in this link and add a post install script for now.

RenzoPH commented 1 year ago

Hi, anyone are experience these issue?

Processing Info.plist

▸ Running script ‘[CP] Embed Pods Frameworks’

▸ Generating ‘App.app.dSYM’

ARCHIVE FAILED

The following build commands failed:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/runner/Library/Developer/Xcode/DerivedData/App-azlyibamtvkrbhfwntgmcwffjqtw/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh (in target ‘App’ from project ‘App’)

(1 failure)

danidaryaweesh commented 1 year ago

@RenzoPH have you tried updating cocoapods to version 1.12.1? Updating to the mentioned version solved all my issues

pranshuchittora commented 1 year ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

Yohanson555 commented 1 year ago

@RenzoPH have you tried updating cocoapods to version 1.12.1? Updating to the mentioned version solved all my issues

Thanks! Worked for me!

margox commented 1 year ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

God, you saved me!!!!!!!!

aurangs7 commented 1 year ago

I don't have Pods-App-frameworks.sh in my ios project, I am using 0.61.5. Can't update project due to some dependencies.

Please guide

danidaryaweesh commented 1 year ago

@aurangs7 Have you tried following the instructions here ?

aurangs7 commented 1 year ago

Yes @danidaryaweesh I tried that post_install hook, but I got errors on the pod install.

my versions: react-native 0.61.5 cocoa pod 1.12.1

aurangs7 commented 1 year ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

God, you saved me!!!!!!!!

Tried ^^ this fix, I was not able to find find-node.sh file, but I searched 'set -e' on'ios-configure-glog.sh' file The build was success but app is crashing on launch.

Yes @danidaryaweesh I tried that post_install hook, but I got errors on the pod install.

my versions: react-native 0.61.5 cocoa pod 1.12.1

undeath55 commented 1 year ago

I did this "Move the project folder in a path with no spaces (i.e. ~/sub folder name/ReactNativeApp won't work till you have spaces in the path, so move in a path like ~/folder/ReactNativeApp)" and then deleted and re-created the project

RenzoPH commented 1 year ago

Hi everyone, I already fixed the issue that I encounter, I tried to upgrade our xCode version to 14.+ and also the macOS-12 to our pipeline.

NoahSimajji commented 1 year ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

THANKSSS this is working for me!!

Xcode: 14.2 Cocoapod: 1.12.1

VladislavYakonyuk commented 1 year ago

If you have tried everything, check if port 8081 is busy (metro uses it by default). I was working with java before and I had eureka running on port 8081, I freed the port, rebuilt it and it worked

sahilbakoru commented 1 year ago

I did this "Move the project folder in a path with no spaces (i.e. ~/sub folder name/ReactNativeApp won't work till you have spaces in the path, so move in a path like ~/folder/ReactNativeApp)" and then deleted and re-created the project

@undeath55 thank you this solution worked.

Adnan-Bacic commented 1 year ago

i updated to 0.71.11 and did not get this error initially when running yarn ios. it only appeared when i ran the project through xcode. afterwards it also started happening when running yarn ios.

so i deleted derived data:

rm -rf ~/Library/Developer/Xcode/DerivedData

and clear build folder/cache with:

https://github.com/pmadruga/react-native-clean-project

then it worked again when i ran yarn ios. so i will just avoid running the project through xcode.

edit:

xcode working fine again later for whatever reason.

yihu5566 commented 1 year ago

Facing the same issue.

rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/97f6331a-ba75-11ed-a4bc-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]

Command PhaseScriptExecution failed with a nonzero exit code

UPDATE adding '-f' on the highlighted line in this file resolved my issue. You can try this

Screenshot 2023-04-13 at 9 56 22 AM

my flutter project have same issue ,This will fix it,thank you

rishiankush commented 1 year ago

source="$(readlink -f "${source}")" did not fix for me. I am using M2 pro and xcode 14.3 React native version: 0.65.3

carlosriveroib commented 1 year ago

source="$(readlink -f "${source}")" is already in my pods configuration, it still failing when I try to run the project on my iPhone wired connected to my M1 pro with xcode 14.3 (also tried 14.3.1 and 14.2) with react-native 0.71 and 0.72

DARPANMANEK commented 1 year ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

works for me too!

sunny0092 commented 1 year ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

works for me too!

Thanks you, fix work me

saravana-mitrah commented 1 year ago

I'm getting this issue in m1 mac. Can anyone give some exact solution for this?

image
ggiordani95 commented 1 year ago

adding -f but doesn't work yet in m1 Mac too

Captura de Tela 2023-07-05 às 10 19 23
saravana-mitrah commented 1 year ago

@ggiordani95 Yes it not working for me

juyeong-s commented 1 year ago

Check if the folder name contains an empty string in the project path! I had the same error as above, but I changed the folder name and solved it!

In m1 mac.

mhmdiqbal commented 1 year ago

Could you please check if you encounter any errors like 'node_modules: No such file or directory' during the 'pod install' process? If you come across such a message, the issue might be related to the unavailability of that path.

In my case, I'm using an external SSD, and sometimes my Mac assigns a name like 'SSD 1' to the SSD. If the name of the SSD contains spaces, it could potentially cause problems with the path. Therefore, it's worth investigating why the specified path cannot be found.

Thank you!

Yandamuri commented 12 months ago

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn't made any difference.

worked for me. Thank you. But, Do you have any idea about permanent solution?

netzwerg commented 11 months ago

I fixed it by configuring the NODE_BINARY variable inside .xcode.env (available as of RN 0.69):

export NODE_BINARY=/Users/xxx/bin/node
JanBartos6 commented 11 months ago

The same problem with Xcode 14.3.1 and M1 Mac. I'm trying to run my kivy python app on an iPhone emulator.

NicholusMuwonge commented 11 months ago

In my case, I had removed Sentry from the project but some of its scripts were left behind in the project.pbxproj under the folder [project_name].xcodeproj. I went ahead and removed them manually and it was resolved.

Homs99 commented 11 months ago

A mi me funciono esto, estoy usando capacitor

Xcode 14.3.1

rotateX commented 11 months ago

@rishiankush did you fix it? i have same issue on M2 pro and xcode 14.3

rotateX commented 11 months ago

@yihu5566 请问你的是m2 pro环境吗 ?我改了还是没解决问题