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

GitHub Action上传Flutter集成测试至Firebase TestLab验证失败求助

解决Firebase Test Lab上传iOS Flutter集成测试Zip包失败问题

问题概述

通过GitHub Action工作流生成的ios_tests.zip上传至Firebase Test Lab时,触发以下错误:

Matrix [matrix-1aenoclku3vww] failed during validation: The XCTest zip file was malformed. The zip did not contain a single .xctestrun file and the contents of the DerivedData/Build/Products directory..

本地手动生成同结构的Zip包可正常上传,但CI环境生成的包即使解压后内容看似正常,仍无法通过验证,且Firebase控制台找不到对应测试矩阵。

解决方案

1. 修正Zip打包路径结构

Firebase Test Lab要求Zip包根目录直接包含.xctestrun文件和对应的App文件夹,不能存在额外层级。当前CI打包命令可能存在路径嵌套问题,修改打包步骤:

- name: Zip Firebase build
  env:
    PRODUCT_PATH: build/ios_integ/Build/Products
    DEV_TARGET: 15.2
  run: |
    cd "$PRODUCT_PATH"
    zip -r ios_tests.zip "Release-iphoneos" "Runner_iphoneos${DEV_TARGET}-arm64.xctestrun"

2. 修复生成文件的权限

CI环境中Xcodebuild生成的文件权限可能与本地不一致,导致Firebase无法识别,添加权限修复步骤:

- name: Fix build file permissions
  env:
    PRODUCT_PATH: build/ios_integ/Build/Products
  run: |
    chmod -R 755 "$PRODUCT_PATH/Release-iphoneos"
    chmod 644 "$PRODUCT_PATH"/*.xctestrun

3. 指定GCloud CLI版本

旧版本GCloud CLI可能对新格式的XCTest包支持不足,更新setup步骤指定最新版本:

- name: "Set up Cloud SDK"
  uses: "google-github-actions/setup-gcloud@v0"
  with:
    version: "latest"

4. 验证Zip包结构

在CI中添加步骤检查Zip包内容,确保结构符合要求:

- name: Validate zip structure
  env:
    ZIP_LOCATION: build/ios_integ/Build/Products/ios_tests.zip
  run: |
    echo "Checking zip contents:"
    unzip -l "$ZIP_LOCATION"
    # 预期输出应显示根目录下直接存在Release-iphoneos文件夹和对应的.xctestrun文件

5. 确认Build产物路径正确性

添加步骤检查Xcodebuild生成的产物目录,确保文件存在:

- name: Verify build products
  env:
    PRODUCT_PATH: build/ios_integ/Build/Products
  run: |
    echo "Listing Products directory:"
    ls -la "$PRODUCT_PATH"

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 09:23:08