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

Expo iOS归档构建失败但模拟器构建成功,求解决方案

Expo SDK49 + Xcode15.0.1 iOS归档失败:main.jsbundle不存在的解决方案

解决方案1:手动生成并复制main.jsbundle

  • 在项目根目录执行命令生成bundle文件:
    npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
    
  • 将生成的ios/main.jsbundle文件复制到报错提示的目标路径:
    /Users/expo/Library/Developer/Xcode/DerivedData/ElectricWeb-dxhammxcxpudvmflxlgofhygnywo/Build/Intermediates.noindex/ArchiveIntermediates/ElectricWeb/BuildProductsPath/Release-iphoneos/ElectricWeb.app/

解决方案2:修改Xcode打包脚本

  • 打开Xcode,进入项目的Build Phases面板,找到Bundle React Native code and images脚本
  • 在脚本开头添加判断逻辑,确保bundle文件不存在时自动生成:
    if [ ! -f "$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/main.jsbundle" ]; then
      npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output "$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/main.jsbundle" --assets-dest "$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH"
    fi
    
  • 保存脚本后重新执行归档操作

解决方案3:清理全量缓存后重建

  • 清理Expo缓存:
    npx expo start --clear
    
  • 清理Xcode缓存:
    1. 按下Cmd+Shift+K清理Xcode构建文件夹
    2. 删除报错路径中的DerivedData目录:
      rm -rf /Users/expo/Library/Developer/Xcode/DerivedData/ElectricWeb-dxhammxcxpudvmflxlgofhygnywo
      
  • 重新打开Xcode执行归档

解决方案4:适配Xcode15兼容性

  • 确保项目的react-native版本为0.72.6及以上(Expo SDK49对应react-native 0.72.x),版本过低则升级
  • 修改ios/Podfile,添加Xcode15适配配置:
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == "React-Core"
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
          end
        end
      end
    end
    
  • 执行pod install更新依赖后重新归档

内容的提问来源于stack exchange,提问作者Ravi Lour

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 14:25:02