main.jsbundle 不存在。这一定是一个错误'

当我尝试从 Xcode 13.3 运行 React 本机应用程序时,我不断收到此错误。

如果我从终端( react-native run-ios )运行它,它工作正常。

请查找随附的错误详细信息。

>     > File /Users/Library/Developer/Xcode/DerivedData/appName-crvjvqqnpdxpwkfkxccvnxunhhkw/
Build/Products/Release-iphonesimulator/appName.app/main.jsbundle
> does not exist. This must be a bug with'
My Environment details

MAC OS - 12.3.1 (M1 chip)
Xcode - 13.3
command line tools - 13.3
RN version - 0.61.5

解决方案我到目前为止已经尝试过

npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

(Xcode) -Build Phases -> Bundle React Native code and images , change to

cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh

请让我知道如何解决此错误。

stack overflow main.jsbundle does not exist. This must be a bug with'
原文答案

答案:

作者头像

这是在 0.63.3 中解决的。 https://github.com/facebook/react-native/issues/29351

如果您对更高版本仍有问题,请尝试手动运行 react-native bundle 命令。

作者头像

Run

sudo xcode-select --reset

Then run

npx react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle

main.jsbundle should appear in your ios folder.

Then add this file in xcode:

enter image description here

enter image description here