React Native从0.63.0升级到0.64.0编译报错:找不到module map文件
React Native 0.64升级后lottie-react-native编译报错解决方案
问题重现
升级React Native从0.63.0到0.64.0后,编译iOS项目时出现错误:
fatal error: module map file '/Users/iteme/Library/Developer/Xcode/DerivedData/apparta-bdsropvgtdqyxfbzxyuwoltrneow/Build/Products/Debug-iphonesimulator/lottie-react-native/lottie_react_native.modulemap' not found
环境信息:
lottie-ios: ^3.1.8lottie-react-native: ^4.0.2- CocoaPods: 1.11.2
已尝试无效操作:删除DerivedData、Podfile.lock、pod install、react-native link、重装lottie-ios
解决方案
1. 修正依赖版本兼容性
RN 0.64与lottie-react-native@4.0.2存在兼容性问题,建议降级到适配RN 0.64的版本:
# 卸载现有依赖 npm uninstall lottie-react-native lottie-ios # 安装适配版本 npm install lottie-react-native@3.7.2 lottie-ios@3.1.8
2. 彻底清理Pod缓存并重装
进入iOS目录执行以下命令:
cd ios # 删除Pod文件和缓存 rm -rf Pods Podfile.lock pod cache clean --all # 更新Pod仓库并重装 pod install --repo-update
3. 强制锁定Pod依赖版本(可选)
如果上述步骤仍无效,在ios/Podfile中手动指定依赖路径和版本,避免CocoaPods自动拉取不兼容版本:
# 在Podfile末尾添加 pod 'lottie-ios', '3.1.8' pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
添加后再次执行pod install
4. Xcode深度清理
- 关闭Xcode
- 删除DerivedData:
rm -rf ~/Library/Developer/Xcode/DerivedData - 打开Xcode,执行
Product > Clean Build Folder(快捷键Cmd+Shift+K) - 重新编译项目
内容的提问来源于stack exchange,提问作者edgar alfaro
相关产品推荐
相关产品推荐

