# How to call fastlane scan with the --clean parameter using CircleCI?

**URL:** <https://discuss.circleci.com/t/how-to-call-fastlane-scan-with-the-clean-parameter-using-circleci/32480>\
**Category:** Build Environment\
**Tags:** fastlane, swift\
**Created:** [September 17, 2019, 3:31am UTC](https://discuss.circleci.com/t/how-to-call-fastlane-scan-with-the-clean-parameter-using-circleci/32480 "2019-09-17T03:31:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![haikusw](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/haikusw/32/23204_2.png) [@haikusw](https://discuss.circleci.com/u/haikusw)\
**Post date:** [September 17, 2019, 3:31am UTC](https://discuss.circleci.com/t/how-to-call-fastlane-scan-with-the-clean-parameter-using-circleci/32480/1 "2019-09-17T03:31:16Z")

</div>

We have an Xcode 11 iOS project and we added some swift packages to the project as dependencies. This is causing some issue with CircleCI (builds fine locally). We don’t have a fastlane configuration file, just the .circleci/config.yml.

First issue is Xcode 11 issue that it has to use https dependency url scheme. This required overriding the forced switch to ssh+git that circleci does via:

```
      - run:
          name: Override CircleCI GitHub URL rewriting
          command: git config --global --unset url."ssh://git@github.com".insteadOf

```

and then changing all our package dependencies to use https urls (pain, but it works). However, then there are issues with the swift package cache (possibly from the previous failed attempts).

I had hoped to add `--clean` to the fastlane command, as in:

```
      - run:
          name: Build and run tests
          command: fastlane scan --clean
          environment:
            SCAN_DEVICE: iPhone 11 (13.0)
            SCAN_SCHEME: CircleCIScheme

```

> xcodebuild: error: Could not resolve package dependencies:  
> An unknown error occurred. ‘/Users/distiller/Library/Developer/Xcode/DerivedData/TestProject-bivykjtderujuveypcdernfqexxy/SourcePackages/repositories/CwlCatchException-463e8527’ exists and is not an empty directory (-4)

I get the same thing if I try it without the dashes as `command: fastlane scan clean`

I _can_ get the build to work (at least most of the time) if instead of adding `--clean` to the `fastlane scan` command I instead add an xcodebuild and clean run command first:

```
      - run: 
          name: xcode clean (fixes stale package cache)
          command: xcodebuild -scheme CircleCIScheme -project ./TestProject.xcodeproj clean

```

seems to work, doing this first:

> #!/bin/bash -eo pipefail  
> xcodebuild -scheme CircleCIScheme -project ./TestProject.xcodeproj clean  
> ^D^DResolve Package Graph
> 
> Fetching [https://github.com/redactedorg/CwlPreconditionTesting.git](https://github.com/redactedorg/CwlPreconditionTesting.git)
> 
> Fetching [https://github.com/redactedorg/CwlCatchException.git](https://github.com/redactedorg/CwlCatchException.git)
> 
> Cloning [https://github.com/redactedorg/CwlCatchException.git](https://github.com/redactedorg/CwlCatchException.git)
> 
> Checking out [https://github.com/redactedorg/CwlCatchException.git](https://github.com/redactedorg/CwlCatchException.git) at 2.0.0-beta.1
> 
> Cloning [https://github.com/redactedorg/CwlPreconditionTesting.git](https://github.com/redactedorg/CwlPreconditionTesting.git)
> 
> Checking out [https://github.com/redactedorg/CwlPreconditionTesting.git](https://github.com/redactedorg/CwlPreconditionTesting.git) at 2.0.0-beta.3
> 
> Resolved source packages:  
> CwlCatchException: [https://github.com/redactedorg/CwlCatchException.git](https://github.com/redactedorg/CwlCatchException.git) @ 2.0.0-beta.1  
> CwlPreconditionTesting: [https://github.com/redactedorg/CwlPreconditionTesting.git](https://github.com/redactedorg/CwlPreconditionTesting.git) @ 2.0.0-beta.3
> 
> note: Using new build system
> 
> \*\* CLEAN SUCCEEDED \*\*

but that seems wrong. It seems like I should be able to pass `clean` to fastlane and have it do the clean and package stuff automatically.

Suggestions? TIA

---

<div class="post-metadata">

**Author:** ![swetaDodiyaiOS](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/swetadodiyaios/32/28733_2.png) [@swetaDodiyaiOS](https://discuss.circleci.com/u/swetaDodiyaiOS)\
**Post date:** [November 24, 2021, 7:55pm UTC](https://discuss.circleci.com/t/how-to-call-fastlane-scan-with-the-clean-parameter-using-circleci/32480/2 "2021-11-24T19:55:00Z")

</div>

I am facing the same issue. Did you get solution to how to clean the build data
