We’re trying to use xcov in Danger to enforce a minimal coverage percentage in our pull requests. Xcov analyses the *.xccoverage files that are in the DerivedData/AppNam-somerandomstring/Logs/Test/ directory. The problem is, it cannot determine this location automatically when run on Bitrise.io.
By default, xcov gets this location using the grandparent directory of SYMROOT from the Xcode build settings (xcodebuild -showBuildSettings). However, this setting seems to change after the Xcode Test step, causing xcov to fail.
We could set the location in the Danger config, but there’s no way to find it using the available environment variables. For now our only option seems to be getting the location by scanning /Users/vagrant/Library/Developer/Xcode/DerivedData/ in a custom Script step.
Do you have any advice on how to get xcov working automatically? Or any better way to find the exact DerivedData location?
Update: I was able to get the correct DerivedData location by using the OBJROOT value from the xcodebuild -showBuildSettings in a custom script step. This is an ugly workaround, so I’d still appreciate some help here.
Unfortunately that’s exactly how you can get the DerivedData AFAIK, as the DD path is generated by xcodebuild and is a hashed value of some parameters of the project, including the path, and the .app etc. pathes inside the DD dir also depend on e.g. the Scheme/Config you build (so it can be different for e.g. Test and Archive actions / builds).
An alternative might be to specify the path of the DerivedData folder, which can be done via an additional param for xcodebuild:
$ xcodebuild -help
...
-derivedDataPath PATH specifies the directory where build products and other derived data will go
...
Keep in mind, depending on your Xcode project configs changing the derived data dir might cause issues. It usually does not, but we did see issues which did not happen when DD path was not modified.
how did you manage to get the .xcactivitylog in the end? I’ve tried numerous tweaks, scripts and changes and I still can’t manage to find the .xcactivitylog files for using xcov and xcprofiler in Danger.
I can get the DerivedData location but the log is not present there (it works locally), just not on Bitrise.
you could try running mdfind -name .xcactivitylog to find where this file is actually, and/or set up a script that parses it to an env var immediately that you can use later
Both I’ve tried and without success I’m currently looking into if the Build for simulator Bitrise step is not deleting the files somehow and instead building the project using a custom script.
EDIT: It is! So it seems the Bitrise Build for simulator step automatically deletes all build data. Using a custom script works fine now.
Glad you found a solution already! In case you’re still interested, I’ll share our solution as well. It’s not pretty, but it works for us
We solved it by adding some lines of bash scripting before the Danger call to add the derived data path to the environment variables: