1、yoga报错
react-native/ReactCommon/yoga/yoga/Yoga.cpp:2285:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
node->getLayout().hadOverflow() |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
||
将 Yoga.cpp:2285:9
的 |
修改成 ||
2、openssl 版本与 node 的兼容问题导致报错容易在 m1/m2 芯片发生
Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:79:19)
at Object.createHash (node:crypto:139:10)
...
{
opensslErrorStack: [
'error:03000086:digital envelope routines::initialization error',
'error:0308010C:digital envelope routines::unsupported'
],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
这是由于openssl版本与node版本在M1/M2芯片兼容问题导致的
解决方法可以参考如下:
1 在 .zshrc
或者 .bashrc
中加入
export NODE_OPTIONS=--openssl-legacy-provider
# 然后 source ~/.zshrc 或者 source ~/.bashrc
2 在 ios
目录下新建 .xcode.env.local
增加
export NODE_OPTIONS=--openssl-legacy-provider
3 如果没效果,在 xcode
打开项目,在 Targets
-> Build Phases
-> Start Packager
加入如下内容
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
export NODE_OPTIONS=--openssl-legacy-provider #需要加入的配置
echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env"
react native 清除缓存 – 可能有效
rm -rf ~/Library/Developer/Xcode/DerivedData/*
watchman watch-del-all
rm -rf $TMPDIR/react-_
rm -rf $TMPDIR/metro-_
rm -rf ios/build
npm cache clean --force
npx pod-install
重新安装 podfile 依赖
pod cache clean --all
pod deintegrate
pod install