React Native项目iOS构建报错Module 'SquareReaderSDK' not found求解决
I’ve run into this exact issue before with React Native 0.60.x and the Square Reader SDK. Let’s walk through the most common fixes step by step:
1. Verify CocoaPods Configuration & Reinstall Pods
React Native 0.60+ uses autolinking, but Square’s SDK relies on a specific CocoaPods source that might not be set up correctly:
- Open your
ios/Podfileand make sure these two sources are at the top of the file (before any target definitions):source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/square/cocoapods-specs.git' - Navigate to your
iosdirectory in terminal and run:
Therm -rf Pods Podfile.lock pod install --repo-update--repo-updateflag ensures you pull the latest Square SDK specs.
2. Check Autolinking Status
Autolinking might have failed silently for the Square SDK:
- Run the manual link command (even though RN 0.60+ uses autolinking, this can help resolve missing links):
react-native link react-native-square-reader-sdk - Re-run
pod installin theiosdirectory after linking.
3. Clear Xcode & Project Caches
Stale caches are a frequent culprit for module not found errors:
- In Xcode, clean the build folder with
Cmd + Shift + K, then delete derived data withCmd + Option + Shift + K. - Delete your project’s
node_modulesfolder, then reinstall dependencies:rm -rf node_modules npm install - Repeat the pod reinstall step from section 1 after this.
4. Validate Framework Search Paths in Xcode
Sometimes the SDK framework path isn’t properly added to your project:
- Open your iOS project in Xcode, select your app target, go to Build Settings.
- Search for
Framework Search Pathsand ensure it includes:$(inherited)(set to recursive)../node_modules/react-native-square-reader-sdk/ios(set to recursive)
- If these paths are missing, add them and rebuild the project.
5. Confirm Version Compatibility
Double-check that your versions play nice together:
react-native-square-reader-sdk 1.3.0is compatible with React Native 0.60.x, but make sure you’re using a supported Xcode version (Square recommends Xcode 10.0+ for this SDK version).- Verify that you’ve completed all initial setup steps for the SDK (like adding the Square app ID to your Info.plist, though this usually causes runtime errors rather than build-time module not found issues).
If you work through these steps in order, the module not found error should resolve itself. Most often, the fix comes down to ensuring the Square CocoaPods source is added and doing a clean reinstall of pods and dependencies.
内容的提问来源于stack exchange,提问作者Muhammad Ashfaq

