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

React Native iOS编译失败求助:video与image-picker模块报错

解决React Native iOS编译失败问题(react-native-video & react-native-image-picker)

针对react-native-video的CompileSwiftSources错误

  • 检查Swift版本配置:打开Xcode,进入项目target的Build Settings,找到Swift Language Version,设置为Swift 5.0及以上版本(RN 0.68.x默认支持该版本,与react-native-video alpha版本兼容)。
  • 清理编译缓存并重新安装依赖:
    rm -rf ~/Library/Developer/Xcode/DerivedData
    cd ios && pod deintegrate && pod install
    
  • 确认自动链接正常:RN 0.68.x支持autolinking,无需手动在Podfile中添加react-native-video,若之前有手动配置,删除后重新执行pod install。

针对react-native-image-picker的CompileC错误

  • 检查架构配置:进入Xcode项目target的Build Settings,将Architectures设置为Standard Architectures (arm64, x86_64),Debug模式下Excluded Architectures不要勾选x86_64(模拟器依赖该架构)。
  • 验证部署目标:确保项目target的Deployment Target设置为iOS 11.0及以上(react-native-image-picker@5.1.0要求最低iOS 11.0,RN 0.68.x默认满足此要求)。
  • 清理Pod缓存:
    cd ios && rm -rf Pods Podfile.lock && pod install
    

通用排查步骤

  • 核对RN升级后的配置:对比RN 0.68.x官方模板项目,检查ios/Podfile、项目xcodeproj的构建设置,确保ENABLE_BITCODE设置为NO(RN 0.68.x默认关闭),避免升级时遗漏关键配置。
  • 全量重装依赖:
    rm -rf node_modules package-lock.json
    npm install
    cd ios && pod deintegrate && pod install
    
  • 查看Xcode详细日志:打开ios/[项目名].xcworkspace直接编译,Xcode会显示具体错误代码或缺失依赖,便于精准定位问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 19:32:09