React Native 0.59.4 iOS端NativeModule.RNLocalize为null的修复求助
Hey there, let’s troubleshoot that stubborn error you’re facing. React Native 0.59.4 is an older version, so there are a few version-specific quirks to check. Here’s what I’d recommend step by step:
1. Verify Library Version Compatibility
First off, newer versions of react-native-localize drop support for older RN releases like 0.59.x. You might have installed a version that’s too new. Run this to install a compatible version:
npm install react-native-localize@1.4.3 --save
This version is confirmed to work with RN 0.59.4. After installing, re-run pod install in the ios directory.
2. Double-Check Your Podfile Configuration
Make sure your ios/Podfile includes the correct entry for RNLocalize. It should look like this:
pod 'RNLocalize', :path => '../node_modules/react-native-localize'
If you had any other references to the library here, remove them to avoid conflicts. Then run:
cd ios pod deintegrate pod install
This ensures a clean pod setup.
3. Manually Verify Xcode Linking (Even with Pods)
Older RN versions sometimes have issues with auto-linking via pods. Open your Xcode project and check these:
- Go to your target’s Build Phases > Link Binary With Libraries and confirm
libRNLocalize.ais listed. If not, add it by clicking the + button and searching for it. - Check Build Settings > Header Search Paths and ensure
$(SRCROOT)/../node_modules/react-native-localize/iosis included with a recursive flag.
4. Nuke All Caches (The Nuclear Option)
Older RN projects hold onto caches like glue. Try this full cleanup:
- Delete node_modules:
rm -rf node_modules && npm install - Clean Xcode build: Open Xcode, press
Cmd+Shift+Kto clean the build folder. - Delete Derived Data: Go to
~/Library/Developer/Xcode/DerivedDataand delete the folder associated with your project. - Reinstall pods:
cd ios && pod deintegrate && pod install
5. Check Info.plist for Localization Settings
react-native-localize relies on your app’s localization configuration. Open ios/[YourProjectName]/Info.plist and add or confirm the CFBundleLocalizations array. For example:
<key>CFBundleLocalizations</key> <array> <string>en</string> <string>zh</string> <!-- Add other languages you support --> </array>
This tells iOS which languages your app supports, which the library needs to initialize properly.
6. Confirm AppDelegate.m Setup (If Required)
Some older versions of react-native-localize required manual initialization in AppDelegate.m. Check if you need this:
- Add the import at the top:
#import <RNLocalize/RNLocalize.h>
- Inside the
didFinishLaunchingWithOptionsmethod, add:
[RNLocalize init];
Not all versions need this, but it’s worth checking if the above steps don’t work.
After going through these steps, rebuild your iOS project in Xcode or run react-native run-ios again. This should resolve the NativeModule null error.
内容的提问来源于stack exchange,提问作者Amine

