NSURL *jsCodeLocation= [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
采用上面的URL方式,报 Application XXX has not been registered错误
可能有两个原因
一、
AppRegistry.registerComponent('项目名',()=>xxx)跟
RCTRootView *rootView = [[RCTRootViewalloc]initWithBundleURL:jsCodeLocation
moduleName:项目名
initialProperties:nil
launchOptions:launchOptions];
的项目名不一致;
二、还有可能是main.jsbundle 文件的缺失,或是不对。需要重新生成该文件。
生成方法:进入到项目根目录(含node_modules文件),先要npm start ,然后再执行
curl http://localhost:8081/index.ios.bundle -o main.jsbundle命令