You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS运行时出现多个modulemap文件找不到错误

React Native iOS 编译报错:找不到多个模块映射文件

操作步骤

我执行以下命令启动React Native iOS项目:

watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install
pod install --repo-update
react-native run-ios --simulator="iPhone 14"

报错信息

运行时触发如下编译错误:

<unknown>:0: error: module map file '/Users/myuser/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk/Build/Products/Debug-iphonesimulator/FirebaseCoreInternal/FirebaseCoreInternal.modulemap' not found
<unknown>:0: error: module map file '/Users/myuser/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found
<unknown>:0: error: module map file '/Users/myuser/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk/Build/Products/Debug-iphonesimulator/lottie-ios/Lottie.modulemap' not found
<unknown>:0: error: module map file '/Users/myuser/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk/Build/Products/Debug-iphonesimulator/lottie-react-native/lottie_react_native.modulemap' not found
<unknown>:0: error: module map file '/Users/myuser/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk/Build/Products/Debug-iphonesimulator/react-native-geolocation-service/react_native_geolocation_service.modulemap' not found
<unknown>:0: error: module map file '/Users/myuser/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk/Build/Products/Debug-iphonesimulator/react-native-in-app-review/react_native_in_app_review.modulemap' not found

补充说明

我的package.json和Podfile配置已整理完毕,且尝试过StackOverflow上的各类常规解决方案,但问题仍未解决。


针对性排查方案

1. 彻底清理Xcode衍生数据

直接删除报错路径对应的DerivedData文件夹:

rm -rf ~/Library/Developer/Xcode/DerivedData/asumobileapp-btkzbdfsdnhmcqayttujwctmcifk

或打开Xcode,按Cmd+Shift+K清理项目,再按Cmd+Option+Shift+K清理构建文件夹。

2. 修复Pod依赖的模块映射路径

打开iOS目录下的Podfile,在post_install钩子中添加强制指定模块映射文件路径的配置:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target_names = ['FirebaseCoreInternal', 'YogaKit', 'lottie-ios', 'lottie-react-native', 'react-native-geolocation-service', 'react-native-in-app-review']
    if target_names.include?(target.name)
      target.build_configurations.each do |config|
        config.build_settings['MODULEMAP_FILE'] = "$(SRCROOT)/#{target.name}/#{target.name}.modulemap"
      end
    end
  end
  react_native_post_install(installer)
end

修改后重新执行:

cd ios && pod install --repo-update

3. 统一iOS部署版本

确保Podfile中的部署版本与项目配置一致,例如设置为13.0或更高:

platform :ios, '13.0'

4. 全链路重置依赖

执行更彻底的清理与重装命令:

watchman watch-del-all
rm -rf node_modules
rm -rf ios/Pods
rm -rf ios/Podfile.lock
yarn cache clean
yarn install
cd ios && pod install --repo-update
cd .. && react-native run-ios --simulator="iPhone 14"

5. 检查Xcode构建架构

打开Xcode项目,进入Build Settings,找到Architectures:

  • 设置为Standard Architectures (arm64, x86_64)
  • Debug模式下可保留Build Active Architecture Only,Release模式建议取消勾选

内容的提问来源于stack exchange,提问作者Raisa A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:13:21