> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/sast-and-sca/prezero/static-analysis-sast/analyzing-applications/swift.md).

# Swift (Beta)

This article shows you how to analyze applications written in Swift using Qwiet AI by Harness. It assumes that you have already [set up and authenticated](broken://spaces/uPVBkglG6gsk2SsnsKgG/pages/fDfomI4jhzwCNFxmGSLc) with Qwiet.

## Requirements <a href="#requirements" id="requirements"></a>

See [Prerequisites](broken://spaces/uPVBkglG6gsk2SsnsKgG/pages/0c1ezDgaUil5NxR4VnY3#language-support-and-requirements) for more information.

## Analyzing your Swift application <a href="#analyzing-your-swift-application" id="analyzing-your-swift-application"></a>

To analyze your Swift application, run:

```
sl analyze --app <name> --swiftsrc <path>
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

| Parameter      | Description                                                                 |
| -------------- | --------------------------------------------------------------------------- |
| `--app <name>` | The name of the application to be analyzed (maximum length: 100 characters) |
| `--swiftsrc`   | The flag identifying the application's language                             |
| `<path>`       | The path to your project                                                    |

See the [CLI reference](broken://spaces/4t03gua31tHpZwtcczPO/pages/bfq0NtVB7O7f6pFvFzK3) for additional `sl analyze` options.

### Additional parameters <a href="#additional-parameters" id="additional-parameters"></a>

The analysis accepts additional parameters after a double hyphen `--`.

```
sl analyze --app <name> --swiftsrc <path> -- ...
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

To exclude specific files or directories from the analysis:

```
sl analyze --app <name> --swiftsrc <path> -- --exclude <path>
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

To exclude files or directories based on a regular expression match:

```
sl analyze --app <name> --swiftsrc <path> -- --exclude-regex <expression>
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

### Swift compiler support <a href="#swift-compiler-support" id="swift-compiler-support"></a>

Type information extraction via the Swift compiler is enabled by passing the `--swift-build` flag in the `sl analyze` command. When set, the tool attempts to compile the target as a Swift Package Manager (SwiftPM) package using `swift build`.

For projects that are not built with SwiftPM (for example, Xcode- or make-based builds), provide a build log that includes all swiftc invocations using the `--build-log-path <path>` option. Generate this log by capturing the output of your normal build process.

```
# SwiftPM project
sl analyze --app <name> --swiftsrc <path> -- --swift-build
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

```
# Xcode/make or other non-SwiftPM projects (using a captured build log)
sl analyze --app <name> --swiftsrc <path> -- --build-log-path <path>
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

For macOS and iOS applications, make sure to run the `sl analyze` command on a host that can successfully compile the project (for example, a macOS machine with the appropriate SDKs and toolchains installed).

![](/files/mlZo7QhbBaWAQlpvEVi9)note

Swift 6.1 or later is required for this functionality.

### Sample usage <a href="#sample-usage" id="sample-usage"></a>

```
sl analyze --app shiftleft-swift-example --swiftsrc .
```

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

## Tagging results with your branch name <a href="#tagging-results-with-your-branch-name" id="tagging-results-with-your-branch-name"></a>

To include the branch name in your Qwiet AI by Harness results, allowing you to distinguish one set of results from another, add the following to your invocation of Qwiet:

```
sl analyze --app shiftleft-swift-example --swiftsrc --tag branch=`git symbolic-ref --short HEAD` .
```

![](/files/CRrxFX9wuboXxDrdB2dv)

![](/files/DfHDmRpYn5HJOmhRtTva) ![](/files/P5vj8JOtHNJWVEvAqKym)

If you're working in a GitHub environment (e.g., [GitHub Actions](https://github.com/features/actions)), you can also use `--tag branch=${{ github.head_ref }}` to populate your branch name.

If you don't provide a branch name, but Qwiet detects one available in your environment, it will use that name.

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

If you have any issues scanning your project, please see our [general troubleshooting page](/sast-and-sca/prezero/tutorials/troubleshooting.md).
