How do I prevent react-native-device-info causing React ambiguity on my setup?

*爱你&永不变心* 提交于 2019-12-06 06:12:31

It turns out that you can link to the react-native in your node_modules, which provides the necessary dependency. This was not done by default in the existing project, so here is the process:

1) Start from "clean" (e.g. with no react-native-device-info behaviour). Having messed around before this, I also found I had to clear out both my node_modules and my ios/Pods directories to clear out the legacy React package.

2) Update your Podfile to link to React (you will also have to add in any relevant subspecs and a separate pod for Yoga)

Here are the lines to add to your 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) Then run react-native link react-native-device-info

This will add react-native-device-info to your Podfile (along with android setup)

pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

4) Install everything as normal: yarn install cd ios pod install

And you should now have a functioning build!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!