事实证明,您可以链接到node_modules中的react-native,它提供了必要的依赖项。现有项目中默认情况下没有这样做,因此流程如下:
1)从“干净”开始(例如没有react-native-device-info
行为)。在此之前搞砸了,我还发现我必须清除我的两个node_modules
and my ios/Pods
目录以清除旧版 React 包。
2)更新你的Podfile以链接到React(你还必须添加任何相关子规格 https://stackoverflow.com/questions/52775976/how-can-i-know-which-react-native-pod-subspecs-to-add和一个单独的瑜伽舱)
以下是要添加到 podfile 中的行:
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'DevSupport',
'Core',
'RCTAnimation',
'RCTImage',
'RCTLinkingIOS',
'RCTSettings',
'RCTText'
]
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
3)然后运行react-native link react-native-device-info
这会将react-native-device-info添加到您的Podfile中(以及android设置)
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
4)正常安装一切:
yarn install
cd ios
pod install
现在您应该已经有了一个可以正常运行的构建!