Freewalker
Freewalker

Reputation: 7335

How can I fully remove a React Native library with a pod?

I'm trying to remove react-native-device-info from our React Native project (in favor of the smaller react-native-version-number).

I've taken these steps:

  1. yarn remove react-native-device-info
  2. cd ios && pod install
  3. Clean build and clear watchman/packager cache
  4. Delete and recreate the JS bundle
  5. grep for any references to react-native-device-info in entire project directory including node-modules (none found)

However, when I run the app I still get these errors. What am I missing?

[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

Upvotes: 3

Views: 6354

Answers (2)

Freewalker
Freewalker

Reputation: 7335

In the current version of react-native, just removing the dependency from package.json and running pod install should work. No manual unlinking is necessary.

We added a yarn postinstall script in package.json as well to always run pod install:

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

Upvotes: 3

react-native unlink react-native-device-info

You need to remove react-native-device-info from your codebase as well, you probably still import it in some file. Also when removing pods remember to reinstall the app and restart the bundler.

Upvotes: 1

Related Questions