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

M1芯片新Mac搭配Xcode 13.1运行fastlane时出现CompileSwiftSources与MergeSwiftModule构建失败问题求助

解决M1 Mac + Xcode 13.1 + Fastlane 出现的MergeSwiftModule/CompileSwiftSources编译错误

我之前在M1芯片的新Mac上用Xcode 13.1跑fastlane时,完全碰到过和你一样的报错:

** TEST BUILD FAILED **
[21:03:58]: ▸ The following build commands failed:
[21:03:58]: ▸ MergeSwiftModule normal x86_64
[21:03:58]: ▸ CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
[21:03:58]: ▸ (2 failures)
❌ error: merge-module command failed with exit code 1 (use -v to see invocation)

本质原因是M1的arm64架构和fastlane默认的x86_64运行环境不兼容,导致Swift模块编译/合并时冲突。给你几个亲测有效的解决办法:

办法1:在Fastfile中指定编译架构

直接在你的fastlane lane配置里添加架构相关的build参数,强制用arm64编译:

lane :your_lane_name do
  build_app(
    workspace: "YourApp.xcworkspace",
    scheme: "YourAppScheme",
    build_settings: {
      "ARCHS" => "arm64",
      "ONLY_ACTIVE_ARCH" => "NO"
    }
  )
end

或者临时在终端运行fastlane时加参数:

fastlane your_lane_name ARCHS=arm64 ONLY_ACTIVE_ARCH=NO

办法2:调整Xcode项目的架构设置

打开Xcode,进入项目的Build Settings:

  • 找到Architectures,设置为arm64(如果需要兼容旧设备,也可以选Standard Architectures (arm64, x86_64),但要保证下面的ONLY_ACTIVE_ARCH在Release模式下为NO)
  • 找到Build Active Architecture Only,Debug模式设为YES,Release模式设为NO
  • 检查Excluded Architectures,确保没有把arm64添加到排除列表里

办法3:用Rosetta模式运行终端

如果上面两种方法都没解决,可能是fastlane版本对M1的兼容还不够。找到终端应用,右键选择「显示简介」,勾选「使用Rosetta打开」,重启终端后再运行fastlane,让终端以x86_64模式运行来适配。

内容的提问来源于stack exchange,提问作者Aakash Wadhwa - iOS Developer

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.27 21:29:07