title: How to detect if iOS app is running in UI Testing mode
body: <p>I would like my app to run special code (e.g. resetting its state) when running in UI Testing mode. I looked at environment variables that are set when the app is running from UI Testing and there aren't any obvious parameters to differentiate between the app running normally vs in UI Testing. Is there a way to find out?</p>
  
  <p>Two workarounds that I'm not satisfied with are:</p>
  
  <ol>
  <li>Set <code>XCUIApplication.launchEnvironment</code> with some variable that I later check in the app. This isn't good because you have to set it in the <code>setUp</code> method of each test file. I tried setting the environment variable from the scheme settings but that doesn't propagate to the app itself when running UI Testing tests.</li>
  <li>Check for the lack of existence of the environment variable <code>__XPC_DYLD_LIBRARY_PATH</code>. This seems very hacky and might only be working now because of a coincidence in how we have our target build settings set up.</li>
  </ol>