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

使用Fastlane在Xcode 16中运行单元测试失败求助

解决Xcode 16中Fastlane run_tests 报错“不支持macOS平台”的问题

问题根源

Xcode 16调整了测试目标的平台检测逻辑,即便未设置macOS部署目标,Fastlane默认的测试执行流程仍可能尝试在Mac平台运行iOS测试目标,引发兼容性冲突。

可行解决方案

  • 强制指定测试运行平台
    在run_tests动作中添加destination参数,明确指定iOS模拟器或设备,避免默认触发Mac平台检测:

    run_tests(
            scheme: scheme,
            fail_build: false,
            code_coverage: true,
            output_directory: "test-reports/#{scheme}",
            destination: "platform=iOS Simulator,name=iPhone 15" # 可根据实际模拟器名称调整
          )
    
  • 修正Scheme配置
    打开Xcode,进入Product > Scheme > Edit Scheme,切换到Test标签页,确认测试目标的运行平台仅勾选iOS相关选项,取消Mac平台的勾选。

  • 升级Fastlane至最新版本
    Xcode 16刚发布,旧版Fastlane可能存在适配漏洞,执行命令升级:

    bundle update fastlane
    # 未使用bundler时可执行:
    gem update fastlane
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 18:12:03