Xcode 云突然无法链接节点和安装依赖项

问题描述 投票:0回答:3

我一直在试图找出为什么这个 xcode 云自定义脚本昨天突然开始对我失败,因为我没有更改任何内容并且它之前一直在工作:

#!/bin/sh

export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew install cocoapods
# have to add node yourself
brew install node@16
# link it to the path
brew link node@16

brew install yarn

# Install dependencies you manage with CocoaPods.
yarn
pod install
# the sed command from RN cant find the file... so we have to run it ourselves
sed -i -e  $'s/ && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)//' /Volumes/workspace/repository/ios/Pods/RCT-Folly/folly/portability/Time.h

由于某种原因,它开始失败并出现以下错误:

==> Installing node@16 dependency: brotli

==> Pouring brotli--1.0.9.monterey.bottle.tar.gz

Error: The `brew link` step did not complete successfully

The formula built, but is not symlinked into /usr/local

Could not symlink include/brotli

/usr/local/include is not writable.

You can try again using:

  brew link brotli

然后它不断给我同样的错误,它无法链接到其他一些依赖项。

当它尝试运行时

yarn
我得到这个:

yarn requires a Node installation to function. You can install one with:

  brew install node

假设节点安装没有成功。

最后是这个:

[in /Volumes/workspace/repository/ios]

[!] Invalid `Podfile` file: cannot load such file -- /Volumes/workspace/repository/node_modules/react-native/scripts/react_native_pods.

 #  from /Volumes/workspace/repository/ios/Podfile:1

 #  -------------------------------------------

 >  require_relative '../node_modules/react-native/scripts/react_native_pods'

 #  require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

 #  -------------------------------------------

sed: /Volumes/workspace/repository/ios/Pods/RCT-Folly/folly/portability/Time.h: No such file or directory

编辑

看来我不是唯一经历过这种情况的人: https://developer.apple.com/forums/thread/712550

这似乎是平台的问题,而不是我的配置的问题。

node.js react-native homebrew xcode-cloud
3个回答
1
投票

将 macOS 版本(在工作流程环境设置中)从“最新版本”更改为 12.4 可能会有所帮助。


1
投票

我设法通过从节点网站的 .tar.gz 安装节点来找到解决方法:

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
node -v
npm -v

另外:如果您需要节点来构建 React Native 应用程序,您需要生成

ios/.xcode.env.local
,以便它导出
$NODE_BINARY

echo "export NODE_BINARY=$(which node)" > ../.xcode.env.local

祝你好运!


0
投票

我在尝试构建 React Native 应用程序时遇到了这个问题。我采用了与@343max类似的方法,但使用brew来安装nvm,然后使用nvm来安装node。

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
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

nvm install 16

然后我创建了一个指向此节点安装的符号链接,以便 Xcode 可以找到它(source)。

sudo mkdir /usr/local/bin
ln -s $(which node) /usr/local/bin/node
© www.soinside.com 2019 - 2024. All rights reserved.