今天突然心血来潮,在 Appdelegate.mm
文件把 react-native 版本从 0.66.2 更新到 0.68.2,重新构建项目时,报了以下图片上的错误。
错误信息是:No visible @interface for 'RCTBundleURLProvider' declares the selector 'jsBundleURLForBundleRoot:fallbackResource:'
经过大部分资料查找,我终于发现了,jsBundleURLForBundleRoot:fallbackResource:
已经不属于 RCTBundleURLProvider
这个类了,我们需要换一种实现方式。
解决办法
把原先的代码
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
替换成
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
然后重新构建 app,一切错误将会消失。