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

M1 Pro Mac下iOS项目编译失败问题求助

解决M1 Pro Mac + CocoaPods + GoogleAnalytics编译问题

一、修复架构不匹配问题(替代全局添加Excluded Architectures)

直接给所有Target加arm64到排除架构容易触发脚本冲突,换精准配置:

  • 打开项目Project级Build Settings(不是单个Target的)
  • 找到Excluded Architectures,针对Debug模式的Any iOS Simulator SDK添加arm64
  • 保持Build Active Architecture Only的Debug设为Yes,Release设为No
  • 修改Podfile,添加以下代码让CocoaPods自动适配Pods Target的架构:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.name == 'Debug' && config.sdk_name&.include?('simulator')
        config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
      end
    end
  end
end
  • 终端执行pod install重新安装依赖

二、解决Command PhaseScriptExecution失败问题

如果架构配置后仍报错,按以下步骤排查:

  • 查看Xcode Report Navigator里的错误详情,定位具体是哪个脚本出错(比如Pods的frameworks脚本或自定义脚本)
  • 若报错脚本是CocoaPods生成的,检查Podfile里的自定义post_install脚本是否有冲突,或某个第三方Pod的安装脚本存在路径问题
  • 给报错脚本添加执行权限:终端中执行chmod +x 脚本完整路径(比如chmod +x Pods/Target Support Files/Pods-YourProject/Pods-YourProject-frameworks.sh)
  • 关闭Xcode的Rosetta模式:右键Xcode图标→显示简介→取消勾选“使用Rosetta打开”,M1 Pro原生编译更稳定,Rosetta可能导致路径混乱
  • 彻底清理缓存:终端执行pod deintegrate && pod clean,删除Derived Data后重新pod install

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 18:51:19