xcparse command in post-actions script always returns error

84 Views Asked by At

I've set up an XCUITest target to automatically make screenshots. What I'm trying to do is automate the export of those screenshots. To do this I'm writing this bash script:

exec > "${PROJECT_DIR}/post_test.log" 2>&1
set -o pipefail
set -e

subparent="$(dirname "$BUILD_DIR")"
derived_data="$(dirname "$subparent")"
test_result_folder="$derived_data/Logs/Test"
files=($test_result_folder/*.xcresult)
filename=${files[@]: -1}

echo "DerivedData path: $derived_data"
echo "Test result folder: $test_result_folder"
echo "Files:"
printf '%s\n' "${files[@]}"
echo "\nMost recent is $filename"

echo /opt/homebrew/bin/xcparse attachments ${filename} ${PROJECT_DIR}/Screenshots | pbcopy

/opt/homebrew/bin/xcparse attachments $filename ${PROJECT_DIR}/Screenshots

The issue here is that the xcparsecommand always returns an error, but if I paste the same command in the terminal it works perfectly. The error is

Error: “/Users/user/Library/Developer/Xcode/DerivedData/MyApp-dhlyvtxfzjxxazcadignzodednxi/Logs/Test/Test-MyAppScreenshotsUITests-2023.03.31_12-27-42-+0200.xcresult” does not appear to be an xcresult

Am I doing something wrong?

0

There are 0 best solutions below