title: fastlane gym - specify derived_data_path but still creates DerivedData in XCode default location as well
body: <p>Am using a fastlane setup on a CI server where I call 'gym' then 'scan'. Both commands are passed the derived_data_path: param to a custom path. What actually happens though is, as soon as gym starts, the standard ~/Library/Developer/XCode/DerivedData path is written to as well as the custom path I have passed to gym. This results in later attempts to clean up the artifacts from DerivedData using clear_derived_data only clearing one of the two DerivedData folders. How can I get xcodebuild/gym to not write to that default ~/Library/Developer/XCode/DerivedData path?</p>
  
  <p>I do notice that the output of the gym command looks different than scan in that the xcodebuild commands for gym dont seem to include the -deriveddata param like I would expect. Here is the output from the console log for gym:</p>
  
  <pre><code>15:34:03 [15:34:03]: -----------------
  15:34:03 [15:34:03]: --- Step: gym ---
  15:34:03 [15:34:03]: -----------------
  15:34:04 [15:34:04]: $ xcodebuild -list -project ./randomprojecthere.xcodeproj -configuration Enterprise
  15:34:05 [15:34:05]: $ xcodebuild clean -showBuildSettings -scheme randomprojecthere\ \(Enterprise\) -project ./randomprojecthere.xcodeproj -configuration Enterprise
  15:34:06 
  15:34:06 +----------------------+---------------------------------------------------------------------------+
  15:34:06 |                                      Summary for gym 2.17.0                                      |
  15:34:06 +----------------------+---------------------------------------------------------------------------+
  15:34:06 | scheme               | randomprojecthere (Enterprise)                                                   |
  15:34:06 | clean                | true                                                                      |
  15:34:06 | configuration        | Enterprise                                                                |
  15:34:06 | export_method        | enterprise                                                                |
  15:34:06 | silent               | true                                                                      |
  15:34:06 | output_directory     | /Users/userhere/.jenkins/jobs/UnifiediPad-Validation/builds/85       |
  15:34:06 | derived_data_path    | /Users/userhere/.jenkins/jobs/UnifiediPad-Validation/builds/85/De... |
  15:34:06 | archive_path         | /Users/userhere/.jenkins/jobs/UnifiediPad-Validation/builds/85/Ar... |
  15:34:06 | output_name          | randomprojecthere                                                     |
  15:34:06 | project              | ./randomprojecthere.xcodeproj                                         |
  15:34:06 | destination          | generic/platform=iOS                                                      |
  15:34:06 | use_legacy_build_api | false                                                                     |
  15:34:06 | buildlog_path        | ~/Library/Logs/gym                                                        |
  15:34:06 | xcode_path           | /Applications/Xcode.app                                                   |
  15:34:06 +----------------------+---------------------------------------------------------------------------+
  15:34:06 
  </code></pre>
  
  <p>And here for scan:</p>
  
  <pre><code>15:34:52 [15:34:52]: $ xcodebuild -list -project ./randomprojecthere.xcodeproj -configuration Debug
  15:34:52 [15:34:52]: $ xcodebuild clean -showBuildSettings -scheme randomprojecthere\ \(Enterprise\) -project ./randomprojecthere.xcodeproj -configuration Debug
  15:34:53 [15:34:53]: $ xcodebuild -list -project ./randomprojecthere.xcodeproj -configuration Debug
  15:34:54 [15:34:54]: $ xcodebuild clean -showBuildSettings -scheme randomprojecthere\ \(Enterprise\) -project ./randomprojecthere.xcodeproj -configuration Debug
  15:34:55 
  15:34:55 +------------------------+-------------------------------------------------------------------------+
  15:34:55 |                                     Summary for scan 2.17.0                                      |
  15:34:55 +------------------------+-------------------------------------------------------------------------+
  15:34:55 | device                 | iPad Air                                                                |
  15:34:55 | scheme                 | randomprojecthere (Enterprise)                                                 |
  15:34:55 | clean                  | false                                                                   |
  15:34:55 | configuration          | Debug                                                                   |
  15:34:55 | output_types           | junit                                                                   |
  15:34:55 | output_directory       | /Users/userhere/.jenkins/workspace/UnifiediPad-Validation/test-... |
  15:34:55 | derived_data_path      | /Users/userhere/.jenkins/jobs/UnifiediPad-Validation/builds/85/... |
  15:34:55 | project                | ./randomprojecthere.xcodeproj                                       |
  15:34:55 | skip_build             | false                                                                   |
  15:34:55 | buildlog_path          | ~/Library/Logs/scan                                                     |
  15:34:55 | include_simulator_logs | false                                                                   |
  15:34:55 | open_report            | false                                                                   |
  15:34:55 | skip_slack             | false                                                                   |
  15:34:55 | slack_only_on_failure  | false                                                                   |
  15:34:55 | use_clang_report_name  | false                                                                   |
  15:34:55 | fail_build             | true                                                                    |
  15:34:55 | xcode_path             | /Applications/Xcode.app                                                 |
  15:34:55 +------------------------+-------------------------------------------------------------------------+
  15:34:55 
  15:34:55 [15:34:55]: $ set -o pipefail &amp;&amp; env NSUnbufferedIO=YES xcodebuild -scheme randomprojecthere\ \(Enterprise\) -project ./randomprojecthere.xcodeproj -configuration Debug -destination 'platform=iOS Simulator,id=3EC3DEA8-6E4C-49E1-91B1-A7E57F44AE94' -derivedDataPath '/Users/userhere/.jenkins/jobs/UnifiediPad-Validation/builds/85/DerivedData' build test | tee '/Users/userhere/Library/Logs/scan/randomprojecthere-randomprojecthere (Enterprise).log' | xcpretty
  </code></pre>
  
  <p>Again, both commands are passed the same custom path values for the derived_data_path: param</p>