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

M1芯片iMac重启后React Native iOS项目编译失败求助

解决方案

M1芯片环境适配修复

  • 用Rosetta模式运行终端:右键终端应用→显示简介→勾选「使用Rosetta打开」,重启终端后进入项目ios目录,执行:
    pod deintegrate && pod install
    
  • 校验Xcode命令行工具路径:执行xcode-select -p确认路径正确,若指向旧版本,执行:
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    
  • 在ios/Podfile末尾添加架构适配配置,重新执行pod install:
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'arm64'
          config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
      end
    end
    

修复「RCTAppDelegate.h找不到」问题

  • 检查Xcode头文件路径:打开Xcode→选中项目Target→Build Settings→Header Search Paths,确保包含以下路径并设为「recursive」:
    • $(SRCROOT)/../node_modules/react-native/React
    • $(SRCROOT)/../node_modules/react-native/ReactCommon
  • 手动触发RN链接:执行npx react-native link(0.70+版本虽自动链接,但极端情况可修复路径异常)

解决xcodebuild错误码70(设备超时)

  • 重置iOS模拟器:打开模拟器→菜单栏「模拟器」→「内容与设置」→「重置」
  • 重启模拟器服务:关闭所有模拟器和Xcode,执行:
    killall -9 com.apple.CoreSimulator.CoreSimulatorService
    
  • 校验模拟器名称:执行xcrun simctl list devices复制正确的模拟器名称,替换命令中的参数后重新执行:
    npm run ios -- --simulator="你的模拟器名称"
    

兜底方案

  • 重装适配M1的CocoaPods:先卸载旧版本sudo gem uninstall cocoapods,再通过Homebrew安装brew install cocoapods,最后进入ios目录执行pod setup && pod install

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 12:33:19