Skip to content

Instantly share code, notes, and snippets.

@iMostfa
Created April 15, 2023 15:57
Show Gist options
  • Save iMostfa/c25749d74c5f5e7282821f563d0b37b6 to your computer and use it in GitHub Desktop.
Save iMostfa/c25749d74c5f5e7282821f563d0b37b6 to your computer and use it in GitHub Desktop.
file.swift
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
# write your script here
# Navigate to DerivedData
cd /Users/vagrant/Library/Developer/Xcode/DerivedData/
# Find the subdirectory (assumes only one subdirectory exists)
subdir=$(find . -maxdepth 1 -type d -not -path '*/\.*' -not -path '.' | tail -n 1)
# Navigate to the Build/ProfileData directory within the subdirectory
cd $subdir/Build/ProfileData
# Find the Coverage.profdata file
coverage_file=$(find . -name 'Coverage.profdata' -type f)
echo "Coverage file found at: $PWD/$coverage_file"
# Find the parent directory
parent_dir=$(find /Users/mostafaessam/Library/Developer/Xcode/DerivedData -name "Wallapop.app" -type d -maxdepth 5 | head -n 1)
if [ -z "$parent_dir" ]; then
echo "Error: Wallapop.app not found"
exit 1
fi
# Navigate to the app bundle directory
cd "$parent_dir"
# Find the Wallapop executable file
executable=$(find . -name "Wallapop" -type f)
if [ -z "$executable" ]; then
echo "Error: Wallapop executable not found"
exit 1
fi
echo "Executable found at: $PWD/$executable"
###########
xcrun --run llvm-cov show -instr-profile=$PWD/$coverage_file \
$PWD/$executable \
> sonarqube-generic-coverage-filtered.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment