xcodereact-nativevisual-studio-codenpmasyncstorage

Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null


I ejected my project from Expo when it was still using Expo. After running it on the iOS simulator, I keep getting this error:

To fix this issue, try these steps:

Uninstall, rebuild, and restart the app.

Run the packager with the --reset-cache flag.

If you are using CocoaPods on iOS, run pod install in the ios directory, then rebuild and re-run the app.

Make sure your project's package.json depends on @react-native-async-storage/async-storage, even if you only depend on it indirectly through other dependencies. The CLI only autolinks native modules found in your package.json.

If this happens while testing with Jest, check out how to integrate AsyncStorage here: AsyncStorage Jest Integration.

After that, I get this: Invariant Violation: "exampleproject" has not been registered.

Some suggest debugging on Android, but I am working on iOS, and I don't have Android installed. Does running it on Android really solve the issue? Additionally, they recommend installing the library using expo install @react-native-async-storage/async-storage, but since I've ejected from Expo, do I need to install Expo again?

How can I solve this problem?

Version

@react-native-async-storage/async-storage": "^2.0.0",

"react-native": "^0.74.5",

enter image description here enter image description here


Solution

  • Check this doc

    On iOS, use CocoaPods to add the native RNAsyncStorage to your project:

    npx pod-install
    

    Maybe this will help you to solve your issue.