As you recognised the .gcda files are put in the "wrong" directory.
Do the following:
- Select your application target in your Xcode-Project and go to "Editor -> Add Build Phase -> Add Run Script Build Phase"
Paste this script into the script field:
echo "Creating derivedDataDirectory file" echo "${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}" > ${PROJECT_DIR}/derivedDataDirectory
(This creates a file with the path to the derivedDataDirectory)
Go to your jenkins project, click on "Add build step" and select "Execute shell".
Paste this script into the "Command" field:
#CopyCodeCoverageFile echo "Start copying code coverage Files" projectname="[YOUR PROJECTNAME]" source=$(cat ${WORKSPACE}/$projectname/derivedDataDirectory) cp -a $source/. ${WORKSPACE}/$projectname/ #CodeCoverage echo "Start CodeCoverage" cd ${WORKSPACE}/$projectname [YOUR PATH TO GCOVR]/gcovr -r /private/tmp/workspace/${JOB_NAME}/$projectname --xml > ${WORKSPACE}/$projectname/test-reports/coverage.xml
Insert [YOUR PROJECTNAME] and [YOUR PATH TO GCOVR]. If your PROJECTNAME or target has spaces in it, this will cause trouble! Make sure all the paths are correct!
- This works for me and if all your paths are correct it should work for you to. Im running XCTests on Jenkins using XCode 5. This should be the same as your setup. If you dont use gcovr to generate code coverage for cobertura you can delete the last step in the script. If you are experiencing problems with gvovr try using gcovr 3.0 instead of 3.1!
Tell me if something is not working for you or you found a better solution!