在原生项目集成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了?
网友评论