RN运行时android调试正常,在ios运行时终端报错,Build编译是正常的
error: bundling failed: NotFoundError: Cannot find entry file index.ios.js in any of the roots: ["/Users/hld/Desktop/project/RN/ZRApp"]
at DependencyGraph.getAbsolutePath (/Users/hld/Desktop/project/RN/ZRApp/node_modules/metro/src/node-haste/DependencyGraph.js:317:11)
at /Users/hld/Desktop/project/RN/ZRApp/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:280:416
at Generator.next (<anonymous>)
at step (/Users/hld/Desktop/project/RN/ZRApp/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:445)
at /Users/hld/Desktop/project/RN/ZRApp/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:605
at process._tickCallback (internal/process/next_tick.js:68:7)
Build编译通过,运行失败,终端以上报错,原因是找不到index.ios
解决方法: 原来在集成官方Pushy热更新的时候,复制了开发文档中的配置Bundle URL代码,
#ifdef DEBUG
//开发包
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@“index.ios" fallbackResource:nil];//错误原因
#else
//离线包
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"bundle/index.ios" withExtension:@"jsbundle"];
jsCodeLocation=[RCTHotUpdate bundleURL];
#endif
在debug时,jsCodeLocation运行index.ios,实际上RN0.44以后是不区分android与ios.js,只需要修改
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@“index" fallbackResource:nil];这一行代码就可以重新编译就解决了