react-native - 如何完全删除带有 pod 的 React Native 库?

标签 react-native cocoapods

我正在尝试从我们的 React Native 项目中删除 react-native-device-info(支持较小的 react-native-version-number)。

我已经采取了这些步骤:

  1. yarn 删除 react-native-device-info
  2. cd ios && pod install
  3. 清理构建并清除 watchman/packager 缓存
  4. 删除并重新创建 JS 包
  5. grep 查找整个项目目录中对 react-native-device-info 的任何 引用,包括节点模块(未找到)

但是,当我运行该应用程序时,我仍然遇到这些错误。我错过了什么?

[Thu Jul 23 2020 14:20:30.622]  ERROR    Error: @react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue try these steps:
  • For react-native <= 0.59: Run `react-native link react-native-device-info` in the project root.
  • Rebuild and re-run the app.
  • If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
  If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-device-info
[Thu Jul 23 2020 14:20:30.623]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Thu Jul 23 2020 14:20:31.746]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

enter image description here

最佳答案

在当前版本的 react-native 中,只需从 package.json 中删除依赖项并运行 pod install 即可。无需手动取消链接。

我们还在 package.json 中添加了一个 yarn postinstall 脚本,以始终运行 pod install:

"postinstall": "(cd ios && pod install)",

关于react-native - 如何完全删除带有 pod 的 React Native 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63061724/

相关文章:

javascript - 防止 axios/fetch 重定向

android - 如何在不使用 ffmpeg 的情况下在 node.js 中编码 h.264

xcode - CocoaPods 是否阻止双击 XCode 项目文件?

ios - 设置 UIAppearance 不会影响 cocoapod UI 组件

ios - 更新后无法使用cocoapods

CocoaPods 更新产生错误加载插件 `slather-2.4.9`

ios - react native : RCT-Folly fatal error - 'fmt/compile.h' file not found

android - react native : how to change view on onPress event

javascript - React-Native 动态图像源?

javascript - 在 React Native 中检测向左滑动