【问题标题】:IDECoverageReportGenerationErrorDomain when generating CodeCoverage for projectIDEOverageReportGenerationErrorDomain 为项目生成 CodeCoverage 时
【发布时间】:2022-06-17 16:16:14
【问题描述】:

我在使用 xcodebuild 命令时遇到了一些问题,希望看看是否有人遇到过类似的问题。

我正在使用 fastlane 扫描进行测试并让它创建代码覆盖,这将在 xcresult 文件中生成代码覆盖信息。在我将 xcargs 添加到组合之前,这一切都很好。

没有 xcargs,我可以在导出数据中的 Logs/Test 中的输出文件上运行 xcrun xccov view --report --json Run-Development-2022.06.09_13-05-00-+0200.xcresult,并获取 JSON 报告以供运行。

当我将 xcargs: "OTHER_SWIFT_FLAGS=\"$(inherited) -Xfrontend -debug-time-function-bodies\" SWIFT_OPTIMIZATION_LEVEL=\"-Owholemodule\"" 添加到 scan() 时,它只会将请求的参数添加到 xcodebuild 命令,但是当我运行上面的相同报告命令时,我在 JSON 文件中收到以下错误:

{
  "code": 0,
  "domain": "IDECoverageReportGenerationErrorDomain",
  "localizedDescription": "Failed to generate coverage for target 'HeadlessUnitTests.xctest' at paths (\n    \"\/Users...}\/HeadlessUnitTests.xctest\/HeadlessUnitTests\"\n):\nmalformed instrumentation profile data"
}
...

好像和xcargs的内容没什么关系,我试过去掉flags以及优化配置,但问题依旧。一起删除 xcargs 将再次起作用。

我的车道:

  desc "Test: makes a clean build and runs all tests."
  lane :test do
    begin
      scan(
        workspace: WORKSPACE, 
        scheme: "Development", 
        configuration: "Debug",
        clean: true, 
        devices: [DEVICE],
        skip_detect_devices: true,
        skip_slack: true,
        code_coverage: true,
        output_directory: './build/',
        output_types: "junit",
        buildlog_path: "#{ENV['GENERIC_FILE_STORAGE']}/build/logs",
        xcargs: "OTHER_SWIFT_FLAGS=\"$(inherited) -Xfrontend -debug-time-function-bodies\" SWIFT_OPTIMIZATION_LEVEL=\"-Owholemodule\"")
    rescue => ex
      UI.user_error! ex
    end
  end

【问题讨论】:

    标签: xcodebuild fastlane fastlane-scan


    【解决方案1】:

    我们(@paul-peelen 和我)一起对此进行了调查,看起来此设置不适用于代码覆盖率:SWIFT_OPTIMIZATION_LEVEL="-Owholemodule"

    我们选择了-0none,它为我们提供了代码覆盖率并极大地提高了我们的测试构建速度。

    【讨论】:

      猜你喜欢
      • 2012-11-20
      • 1970-01-01
      • 2019-12-02
      • 2021-12-27
      • 1970-01-01
      • 2011-03-11
      • 2013-08-06
      • 2021-09-17
      • 1970-01-01
      相关资源
      最近更新 更多