main.jsbundle不存在.这必须是+ echo'反应原生的错误

Lou*_*wan 15 xcode react-native

我尝试使用XCode9.2上的产品 > 存档来存档我的反应原生项目.但是Xcode产生了这个错误:

File /Users/louis/Library/Developer/Xcode/DerivedData/Scavenger-evyvzocndqoghkclcbwewolywniz/Build/Products/Release-iphoneos/Scavenger.app/main.jsbundle does not exist. This must be a bug with


My Environment:
  OS: macOS Sierra 10.12.6
  Node: 9.3.0
  npm: 5.5.1
  Watchman: 4.7.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.0.0 => 16.2.0
  react-native: ^0.50.3 => 0.50.4
Run Code Online (Sandbox Code Playgroud)

我也尝试在终端上运行,
react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/Scavenger/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'但最终出现错误加载依赖图... JSON输入的意外结束

XCode错误.

单击此处查看XCode错误

Cuo*_*Lam 28

这个问题花了我几天时间来修复.我在travis-ci上运行构建时遇到了这个问题.这是我的修复:

将此行添加到scriptspackage.json文件中.

"build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'"

现在您可以运行命令来生成main.jsbundle. yarn build:ios要么npm run build:ios

打开Xcode - >选择项目目标 - >添加main.jsbundleCopy Bundle ResourceBuild Phases.(下图).

Xcode修复

  • 复制捆绑资源步骤对我来说是关键!非常感谢 (4认同)
  • 感谢这个解决方案。由于某种原因,我在安装“react-native-purchases”后遇到了这个问题(这个库仅适用于 rn 版本 0.64+,所以可能与此有关..)我的问题是..我应该每次运行“yarn build:ios”在我存档以部署应用程序的新版本之前?我很困惑为什么它在我安装“react-native-purchases”之前工作得很好,而这个问题在安装它之后发生。所以在我的部署过程中添加这个额外的步骤..任何信息将非常感激! (2认同)

小智 18

在AppDelegate.m中注释这一行

 jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 
Run Code Online (Sandbox Code Playgroud)

使用这一行: -

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 
Run Code Online (Sandbox Code Playgroud)

在那之后运行这个来制作jsbundle: -

 react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Run Code Online (Sandbox Code Playgroud)

在xcode中运行此命令.希望它会捆绑,之后没有这样的错误...... Thanx


小智 8

当您的项目中没有脱机捆绑文件时,就会发生这种情况,而我遇到了同样的问题,并且对我有用。

我已将以下行添加到我的package.json文件下的scripts部分中,因此我不必每次要生成脱机捆绑包时都键入它。

"build:ios": "react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/YourAppName/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"
Run Code Online (Sandbox Code Playgroud)

然后在您的应用程序项目文件夹中运行以下命令:

npm运行build:ios

运行上述命令后,新目录main.jsbundle将在您的ios/YourAppName目录中生成。

接下来,使用XCode打开您的项目,右键单击您的项目名称,然后单击“将文件添加到“ YourProjectName”,选择main.jsbundle生成的文件,然后再次生成。

现在它可能运行良好。

我在用:

 "react": "16.0.0-alpha.12",
 "react-native": "^0.48.3",
Run Code Online (Sandbox Code Playgroud)

  • 对我来说,我需要将 `index.ios.js` 更改为 `index.js` (6认同)

Vin*_*nan 7

推荐使用最新的 Xcode 和 React Native 版本。 我的 React Native 版本:0.56 和 Xcode 10

第1步: 更改AppDelegate.m文件

    //  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#ifdef DEBUG
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
Run Code Online (Sandbox Code Playgroud)

第 2 步: 将 Xcode 构建配置更改为“发布”

转到产品>方案>编辑方案>将调试更改为发布

如果您使用的是 Xcode 10+,请在 File> ProjectWorkSpace Settings> Build System 下将 Build system 更改为 Legacy Build System

步骤3: 将你的“babel-preset-react-native”升级到5.0.1,如果你的package.json文件中不存在,请添加它。

删除 NodeModules 和 package.lock 文件并添加它(npm install 或yarn install)。

第4步: 更改“.babelrc.js”文件

添加 ”presets: ["module:metro-react-native-babel-preset"]

第5步: 打开终端

打开终端并导航到您的项目目录运行此命令

"react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets"
Run Code Online (Sandbox Code Playgroud)

这将在 iOS 文件夹中生成一个“main.jsbundle”文件

第 6 步:将“main.jsbundle”文件添加到 Xcode 中。

打开 Xcode 并导航到“复制捆绑资源”下的“构建阶段”,添加“main.jsbundle”文件。

清理您的项目也会清除 Xcode 中的派生数据。这将以发布模式构建您的项目。

对于“存档”错误

将此依赖项添加到您的“ pod 文件”中

pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'CxxBridge'
  ]
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
Run Code Online (Sandbox Code Playgroud)

删除 pod 和 pod.lock 并再次添加。(吊舱安装)

快乐编码:)


Nas*_*V N 7

在我退出博览会以添加应用内购买后,我遇到了这个问题。我执行了以下操作以使其正常工作

cd <your repo>
npx react-native bundle --entry-file ./index.js --dev false --reset-cache --platform ios --bundle-output ios/main.jsbundle --assets-dest ./ios
Run Code Online (Sandbox Code Playgroud)

运行上述命令后,您必须将 main.jsbundle 和资源拖放到 Xcode 中,并通过引用而不是分组链接它


Raj*_*sit 6

如果您更新 xcode 并收到此错误,那么解决方案是

在根项目的终端中执行以下命令

 1. sudo xcode-select --reset

 2. npx react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle
Run Code Online (Sandbox Code Playgroud)

在第二个命令期间,如果您发现任何与 JS 相关的错误,请修复它 成功运行第二个命令后,此错误将消失