iOS 原生项目集成的RN中使用reactnavigation报错

在原生项目集成RN后,连接npm server 或者加载React Native的bundle 包出现:Native module cannot be null. 的错误,这时,你需要检查下你的cocoapods 里面是否包含了'RCTLinkingIOS'模块,如果没有,加上试试,类似下面这样:

pod 'React', :path => './node_modules/react-native', :subspecs => [
  'Core',
  'CxxBridge', # Include this for RN >= 0.47
  'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
  'RCTText',
  'RCTNetwork',
  'RCTImage',
  'RCTLinkingIOS',
  'RCTWebSocket', # Needed for debugging
  'RCTAnimation', # Needed for FlatList and animations running on native UI thread
  # Add any other subspecs you want to use in your project
  ]

然后再pod install 一下,重新运行项目,是不是就OK了?

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。