React Native archive error: Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies

React Native archive error: Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies

我正在尝试存档我的(否则完美构建,运行宁 simulator/device 用于调试)iOS 使用 React Native 构建的应用程序。

当我尝试在 Xcode 中存档时,它会正确编译和链接,但在尝试生成资产时会调用以下命令:

node '/Users/Can/Documents/Programming/React Native/REDACTED/node_modules/react-native/cli.js' bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/Can/Library/Developer/Xcode/DerivedData/REDACTED-eebdhuhscigvmvduljehleepetoi/Build/Intermediates.noindex/ArchiveIntermediates/REDACTED/BuildProductsPath/Release-iphoneos/REDACTED.app/main.jsbundle --assets-dest /Users/Can/Library/Developer/Xcode/DerivedData/REDACTED-eebdhuhscigvmvduljehleepetoi/Build/Intermediates.noindex/ArchiveIntermediates/REDACTED/BuildProductsPath/Release-iphoneos/REDACTED.app

失败并出现错误:

error Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies.. Run CLI with --verbose flag for more details.

(在你问之前,react-native安装在我的项目依赖中,很明显)

当我手动调用那个确切的节点命令时,它生成的资产非常好:

warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, /Users/Can/Library/Developer/Xcode/DerivedData/REDACTED-eebdhuhscigvmvduljehleepetoi/Build/Intermediates.noindex/ArchiveIntermediates/REDACTED/BuildProductsPath/Release-iphoneos/REDACTED.app/main.jsbundle
info Done writing bundle output
info Copying 30 asset files
info Done copying assets

因此我无法存档我的应​​用程序。它建议我使用带有 --verbose 标志的 运行 CLI,但我不知道在哪里添加标志,因为命令本身是从 autogenerated/complicated 脚本调用的。

我做错了什么?我在 Xcode 10.2 和 React Native 0.59.3.

根据错误确保"react-native"模块已安装您不在项目根路径上。所以删除派生数据并打开终端并设置项目路径

cd ../projectpath_foldername

运行命令

npm start

之后

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

现在运行

react-native run-ios

构建完成后 运行 打开 xcode 并存档您的应用程序。

在调查了一些问题之后 https://github.com/facebook/react-native/issues/22354 我在几个小时后发现了问题:

我的项目路径中有一个 space。我已将我的项目移动到没有 space 的路径,它开始完美存档。显然,这确实是 React Native 的一个错误。