Reputation: 65005
I have a ReactNative project that suddenly fails to build in Xcode Cloud because Node cannot be found. This happens as part of the Run command: 'xcodebuild archive ...'
part of the build. The Node install completes successfully as part of the earlier ci_pre_xcodebuild.sh script, and it is used by yarn
and pod install
successfully.
But it seems a Pod Xcode build file actually has a custom script that wants to use Node again, and at this time it is not found. It appears that the environment variables set up in the ci_pre_xcodebuild.sh script are not found by scripts launched by xcodebuild.
Is it possible to fix this so they are visible?
=== BUILD AGGREGATE TARGET FBReactNativeSpec OF PROJECT Pods WITH CONFIGURATION Release ===
WriteAuxiliaryFile /Volumes/workspace/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Commutyble/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-C002E9D3BBBD3F63C0DD29E56E81D563.sh (in target 'FBReactNativeSpec' from project 'Pods')
cd /Volumes/workspace/repository/ios/Pods
write-file /Volumes/workspace/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Commutyble/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-C002E9D3BBBD3F63C0DD29E56E81D563.sh
PhaseScriptExecution [CP-User]\ Generate\ Specs /Volumes/workspace/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Commutyble/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-C002E9D3BBBD3F63C0DD29E56E81D563.sh (in target 'FBReactNativeSpec' from project 'Pods')
cd /Volumes/workspace/repository/ios/Pods
/bin/sh -c /Volumes/workspace/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Commutyble/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-C002E9D3BBBD3F63C0DD29E56E81D563.sh
error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable.
Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable.
Local builds are fine. I am running an old ReactNative 0.68 and Xcode 14.3.1. Below is the script that installs Node and echoes out the paths to it as seen in the build log output here:
NODE_PATH is /Volumes/workspace/repository/ios/ci_scripts/node-v16.20.2-darwin-x64/bin
PATH is :/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/bin:/Users/local/Homebrew:/Users/local/Homebrew/bin:/usr/local/bin:/Users/local/Homebrew:/Users/local/Homebrew/bin:/Volumes/workspace/repository/ios/ci_scripts/node-v16.20.2-darwin-x64/bin
/Volumes/workspace/repository/ios/ci_scripts/node-v16.20.2-darwin-x64/bin/node
NODE_BINARY is /Volumes/workspace/repository/ios/ci_scripts/node-v16.20.2-darwin-x64/bin/node
v16.20.2
8.19.4
ci_pre_xcodebuild.sh
#!/bin/sh
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew install cocoapods
# have to add node yourself
NODE_VER=16
VERSION=$(curl -s https://nodejs.org/dist/latest-v$NODE_VER.x/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')
if [[ "$(arch)" == "arm64" ]]
then
ARCH="arm64"
else
ARCH="x64"
fi
curl "https://nodejs.org/dist/latest-v$NODE_VER.x/node-$VERSION-darwin-$ARCH.tar.gz" -o $HOME/Downloads/node.tar.gz
tar -xf "$HOME/Downloads/node.tar.gz"
NODE_PATH="$PWD/node-$VERSION-darwin-$ARCH/bin"
PATH+=":$NODE_PATH"
export PATH
echo "NODE_PATH is $NODE_PATH"
echo "PATH is $PATH"
export NODE_BINARY=`which node`
which node
echo "NODE_BINARY is $NODE_BINARY"
node -v
npm -v
brew install yarn
# Install dependencies you manage with CocoaPods.
yarn
pod install
Upvotes: 0
Views: 151