title: Can xcodebuild delete the contents of the project's Build Folder?
body: <p>Back in Xcode 9, there was a build option called &quot;Clean Build Folder...&quot; (<kbd>⌥</kbd><kbd>⇧</kbd><kbd>⌘</kbd><kbd>K</kbd>), which deleted all files in the build folder, only leaving the folder behind with no contents. Since then, this behavior was removed, the menu item's title changed to &quot;Clean Build Folder&quot;, and now behaving like the old &quot;Clean&quot; used to.</p>
  <p><code>xcodebuild</code> has a build option called <code>clean</code> which simply does the same thing as Xcode's &quot;Clean Build Folder&quot; (<kbd>⌘</kbd><kbd>⇧</kbd><kbd>K</kbd>), which leaves stuff around.</p>
  <p><strong>Is there any way to delete all files in the build folder via a scriptable command?</strong></p>
  <hr />
  <p>What I've tried so far:</p>
  <pre class="lang-bash prettyprint-override"><code>xcodebuild clean -workspace &quot;My Workspace.xcworkspace&quot; -scheme &quot;My Scheme&quot;
  </code></pre>
  <p>This, as I said, doesn't actually clean everything up. For that, I added this bodge to my build script:</p>
  <pre><code>export IS_XCODE_CACHE_FOLDER_PRESENT=&quot;`ls -la ~/Library/Developer/ | grep -x &quot;Xcode&quot;`&quot;
  
  if [ 0 -ne &quot;$IS_XCODE_CACHE_FOLDER_PRESENT&quot; ]; then
      echo &quot;Xcode cache folder should not be present at build time! Attempting to delete...&quot;
      rm -rf &quot;~/Library/Developer/Xcode&quot;
      RM_RESULT=$?
      if [ 0 -ne &quot;$RM_RESULT&quot; ]; then
          echo &quot;FAILED to remove Xcode cache folder!&quot;
          exit $RM_RESULT
      fi
  fi
  </code></pre>