<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2026-03-29T14:26:52+00:00</updated><id>/feed.xml</id><title type="html">lorenzoboaro.io</title><subtitle>Yet another site where you can find useful coding stuff.</subtitle><entry><title type="html">Experimenting with Fastlane scan</title><link href="/fastlane/fastlane-scan/2026/03/29/experimenting-with-fastlane-scan.html" rel="alternate" type="text/html" title="Experimenting with Fastlane scan" /><published>2026-03-29T13:00:00+00:00</published><updated>2026-03-29T13:00:00+00:00</updated><id>/fastlane/fastlane-scan/2026/03/29/experimenting-with-fastlane-scan</id><content type="html" xml:base="/fastlane/fastlane-scan/2026/03/29/experimenting-with-fastlane-scan.html"><![CDATA[<p>scan, aka run_tests, is a powerful fastlane action which allows you to automate Unit Tests for iOS applications.</p>

<p>Using scan action is quite simple. For example, a simple configuration could look like the following:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>scan(
  workspace: "path/to/MyAwesomeApp.xcworkspace",
  derived_data_path: "path/to/derived_data",
  scheme: 'MyAwesomeApp',
  output_directory: 'path/to/reports'
  clean: true
)
</code></pre></div></div>

<p>Under the hood scan makes usage of default parameters that, if not fine tuned correctly, could increase the time to complete the action itself.</p>

<p>In small projects the increased time could not be an issue, but in large projects, if you want to make the automation faster, you could end up overloading your CI / CD environment.</p>

<p>To understand better if default parameters may increase the completion time for running tests, I’ve performed few experiments within a quite large project, a mix of Swift and Objective-C, using a MacBook Pro with an Apple M1 Pro chip.</p>

<p>First of all, scan action comes with the parameter <code class="language-plaintext highlighter-rouge">skip_build</code> which is set to <code class="language-plaintext highlighter-rouge">false</code>. Leaving the parameter with its default value is the same as the following xcodebuild command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>xcodebuild \
  -workspace MyAwesomeApp.xcworkspace \
  -scheme MyAwesomeApp \
  -sdk iphonesimulator \
  -destination 'platform=iOS Simulator,id=&lt;redacted&gt;' \
  build test
</code></pre></div></div>

<p>After setting <code class="language-plaintext highlighter-rouge">skip_build</code> to <code class="language-plaintext highlighter-rouge">true</code> (why is build action needed?), the completion time for running tests has been decreased by up to 50% of the inital value.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>scan(
  workspace: "path/to/MyAwesomeApp.xcworkspace",
  derived_data_path: "path/to/derived_data",
  scheme: 'MyAwesomeApp',
  output_directory: 'path/to/reports'
  clean: true,
  skip_build: true
)
</code></pre></div></div>

<p>This is a fantastic result but I’m not still satisfied.</p>

<p>Reading at the documentation, I’ve found another parameter called <code class="language-plaintext highlighter-rouge">output_style</code> which defines how the output should look like. By default (when not set), scan uses xcpretty to format the console output in a prettier way.</p>

<p>After setting <code class="language-plaintext highlighter-rouge">output_style</code> to <code class="language-plaintext highlighter-rouge">raw</code> (disabling xcpretty), the completion time has been decreased by up to 90% of the inital value.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>scan(
  workspace: "path/to/MyAwesomeApp.xcworkspace",
  derived_data_path: "path/to/derived_data",
  scheme: 'MyAwesomeApp',
  output_directory: 'path/to/reports'
  clean: true,
  skip_build: true,
  output_style: 'raw' 
)
</code></pre></div></div>

<p>This is amazing!</p>

<p>There is a gotcha disabling xcpretty, though: html or junit reports are not generated anymore.</p>

<p>Since not still satisfied, I’ve reread with care scan documentation and I’ve found two additional parameters: <code class="language-plaintext highlighter-rouge">build_for_testing</code> and <code class="language-plaintext highlighter-rouge">test_without_building</code>.</p>

<p>Unfortunately the documentation does not describe too much about them. But then I’ve found a WWDC 2016 video (unlisted on Apple Developer site) that explains the purpose of them.</p>

<p>build_for_testing is an xcodebuild action that:</p>
<ul>
  <li>builds sources for testing</li>
  <li>outputs products in Derived Data</li>
  <li>generates an xctestrun file</li>
</ul>

<p><code class="language-plaintext highlighter-rouge">test_without_building</code>, instead, consumes the outputs of the previous action to run tests against the xctestrun file.</p>

<p>With this in mind I’ve tried another experiment splitting the scan action into two different parts. In this manner I was able to maintain html and junit report generated by scan.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>scan(
  workspace: "path/to/MyAwesomeApp.xcworkspace",
  derived_data_path: "path/to/derived_data",
  scheme: 'MyAwesomeApp',
  clean: true,
  skip_build: true,
  output_style: 'raw',
  build_for_testing: true 
)

scan(
  workspace: "path/to/MyAwesomeApp.xcworkspace",
  derived_data_path: "path/to/derived_data",
  scheme: 'MyAwesomeApp',
  output_directory: 'path/to/reports'
  clean: true,
  skip_build: true,
  test_without_building: true
)
</code></pre></div></div>]]></content><author><name></name></author><category term="fastlane" /><category term="fastlane-scan" /><summary type="html"><![CDATA[scan, aka run_tests, is a powerful fastlane action which allows you to automate Unit Tests for iOS applications.]]></summary></entry></feed>