I'm having some issues with the xcodebuild command and was hoping to see if anybody has experienced similar issues.
I'm using fastlane scan for testing and having it create the codecoverage as well, this will generate code coverage info in the xcresult file. This works all fine and dany, until I add xcargs to the mix.
Without xcargs, I can run xcrun xccov view --report --json Run-Development-2022.06.09_13-05-00-+0200.xcresult
on the output file in Logs/Test
in derived data and get a JSON report for run.
When I add xcargs: "OTHER_SWIFT_FLAGS=\"$(inherited) -Xfrontend -debug-time-function-bodies\" SWIFT_OPTIMIZATION_LEVEL=\"-Owholemodule\""
to scan()
, it only adds the requested arguments to the xcodebuild command but when I run the same report command above I get the following error in the JSON file:
{
"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"
}
...
It doesn't seem to have anything to do with the contents of xcargs
, I've tried removing the flags as well as the optimisation configuration, but the problem persists. Removing the xcargs all together will work again.
My lane:
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