main.jsbundle 不存在。升级到 react-native 0.63 后,这一定是一个带有 .. main.jsbundle 问题的错误

cha*_*gey 18 xcode ios react-native

“反应”:“16.13.1”,“反应原生”:“0.63.0”,

遇到下面的main.jsbundle不存在。在升级到 react-native 0.63 后尝试存档时,这一定是一个有问题的错误。想知道是否有人遇到同样的问题

在此处输入图片说明

Isa*_*ker 17

这在一个涉及babel-plugin-module-resolver以下项目的项目中对我有用:

  1. ios/*.xcworkspace在 Xcode 中打开您的。
  2. Click on the name of your project in the project navigator.
  3. Click on the name of your target in the pane on the left.
  4. Click on Build Phases.
  5. Expand the Bundle React Native code and images phase.
  6. On the first line of the script, add cd $PROJECT_DIR/.. to go up a directory.

The whole script should look like this:

cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh
Run Code Online (Sandbox Code Playgroud)

Note that this might break if the source of this is a bug in 0.63.0, so you may need to undo this on a future release.

Props to @typester for bringing this up on facebook/react-native #29351.


cha*_*gey 6

找到了解决办法

  1. 在 Xcode Build Phases -> Copy Bundle Resources 中,添加 main.jsbundle

在此处输入图片说明

  1. package.json,添加
"scripts": {
    "bundle:ios": "react-native bundle --entry-file index.ios.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios",
    "postinstall": "yarn run bundle:ios"
    ...
  },
Run Code Online (Sandbox Code Playgroud)

所以main.jsbundle会产生

  • 您知道最初是什么促使这种变化吗?当然,这看起来很合乎逻辑,但为什么之前不需要“react-native bundle”调用呢? (2认同)
  • 对我来说这也有效,但也不包含任何资产。 (2认同)