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错误.
Cuo*_*Lam 28
这个问题花了我几天时间来修复.我在travis-ci上运行构建时遇到了这个问题.这是我的修复:
将此行添加到scripts
package.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.jsbundle
到Copy Bundle Resource
Build Phases.(下图).
小智 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)
推荐使用最新的 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 并再次添加。(吊舱安装)
快乐编码:)
在我退出博览会以添加应用内购买后,我遇到了这个问题。我执行了以下操作以使其正常工作
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 中,并通过引用而不是分组链接它
如果您更新 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 相关的错误,请修复它 成功运行第二个命令后,此错误将消失