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

Fastlane与GitHub Actions测试失败:Scan无法识别模拟器求解决

解决方案:Fastlane Scan 找不到模拟器的问题

1. 显式指定模拟器设备信息

在Fastlane的scan配置里直接指定具体的模拟器参数,避免自动匹配失败:

  • 先在GitHub Actions runner中列出可用模拟器,确认设备信息:
    xcrun simctl list devices
    
  • 然后在Fastfile的lane中硬编码目标设备:
    lane :test do
      scan(
        scheme: "你的Scheme名称",
        destination: "platform=iOS Simulator,name=iPhone 15,OS=17.0"
        # 也可以用UDID精准匹配:destination: "id=XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
      )
    end
    

2. 提前在GitHub Actions中创建指定模拟器

GitHub Actions默认的macOS runner可能缺少你需要的模拟器版本,需提前创建并启动:
在Actions的yml文件中,执行Fastlane前添加以下步骤:

- name: 创建并启动iOS模拟器
  run: |
    xcrun simctl create "iPhone 15" com.apple.CoreSimulator.SimDeviceType.iPhone-15 com.apple.CoreSimulator.SimRuntime.iOS-17-0
    xcrun simctl boot "iPhone 15"

3. 校验项目Deployment Target与模拟器版本匹配

确保项目的Deployment Target版本 ≤ 指定的模拟器系统版本,否则xcodebuild会判定设备不兼容。

4. 强制指定Xcode路径

GitHub Actions中可能存在多版本Xcode冲突,显式指定目标Xcode路径:

  • 在Fastfile中添加:
    lane :test do
      xcode_select "/Applications/Xcode_15.app" # 根据runner实际安装的Xcode版本调整路径
      scan(
        # 你的scan配置
      )
    end
    
  • 或者在Actions的yml中先设置:
  • name: 选择指定Xcode版本
    run: sudo xcode-select -s /Applications/Xcode_15.app

5. 清理项目缓存后再执行测试

缓存可能导致配置异常,测试前先清理:

  • 在Fastfile中添加清理步骤:
    lane :test do
      clean_build_artifacts
      scan(...)
    end
    
  • 或者在Actions的yml中单独执行清理:
  • name: 清理项目
    run: xcodebuild clean -scheme 你的Scheme名称 -destination 'platform=iOS Simulator,name=iPhone 15'

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 20:57:38