Skip to content
A source code analyzer for Swift projects.
Swift Other
  1. Swift 99.7%
  2. Other 0.3%
Branch: master
Clone or download

Latest commit

twostraws Merge pull request #8 from alexito4/fix-#1
Fixes #1 - improved type length analysis
Latest commit fbbf366 Feb 20, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Rename action to unittests Feb 8, 2020
Sources Fixes #1 Feb 11, 2020
Tests Fixes #1 Feb 11, 2020
Working Initial commit. Feb 6, 2020
.gitignore Added JSON output format support Feb 8, 2020
.swiftlint.yml Initial commit. Feb 6, 2020 Initial commit. Feb 6, 2020
LICENSE Initial commit. Feb 6, 2020
Package.resolved Initial commit. Feb 6, 2020
Package.swift Initial commit. Feb 6, 2020 Merge remote-tracking branch 'upstream/master' Feb 10, 2020
makefile added makefile & install info to readme Feb 7, 2020

Sitrep logo

Twitter: @twostraws

Sitrep is source code analyzer for Swift projects, giving you a high-level overview of your code:

  • A count of your classes, structs, enums, protocols, and extensions.
  • Total lines of code, and also source lines of code (minus comments and whitespace).
  • Which file and type are the longest, plus their source lines of code.
  • Which imports you’re using and how often.
  • How many UIViews, UIViewControllers, and SwiftUI views are in your project.

Behind the scenes, Sitrep captures a lot more information that could be utilized – how many functions you have, how many comments (regular and documentation), how large your enums are, and more. These aren’t currently reported, but could be in a future release. It’s also written as both a library and an executable, so it can be integrated elsewhere as needed.

Sitrep is built using Apple’s SwiftSyntax, which means it parses Swift code accurately and efficiently.


Sitrep can be used through the Swift Package Manager. You can add it as a dependency in your Package.swift file:

let package = Package(
    dependencies: [
        .package(url: "", .branch("master"))

Then import SitrepCore wherever you’d like to use it.

To install the Sitrep command line tool, clone the repository and run make install:

git clone
cd Sitrep
make install

From now on you can use the sitrep command to scan Swift projects.

Command line flags

sitrep --json
sitrep ~/path/to/your/project/root --json

You can use the optional --json flag to print a pretty formatted JSON output.

Try it yourself

Sitrep is written using Swift 5.1. You can either build and run the executable directly, or integrate the SitrepCore library into your own code.

To build Sitrep, clone this repository and open Terminal in the repository root directory. Then run:

swift build
swift run sitrep ~/path/to/your/project/root

If you would like to keep a copy of the sitrep executable around, find it in the .debug directory after running swift build.

To run Sitrep from the command line just provide it with the name of a project directory to parse – it will locate all Swift files recursively from there. Alternatively, just using sitrep by itself will scan the current directory.

Contribution guide

Any help you can offer with this project is most welcome, and trust me: there are opportunities big and small, so that someone with only a small amount of Swift experience can help.

Some suggestions you might want to explore:

  • Converting more of the tracked data (number of functions, parameters to functions, length of functions, etc) into reported data.
  • Adding a sitrep.yml file that lets users configure how files are scanned, such as the ability to ignore certain directories, what kind of output is printed, or to enable stripped parsing of individual types using BodyStripper.
  • Reading more data from the parsed files, and using it to calculate things such as cyclomatic complexity.
  • Reading non-Swift data, such as number of storyboard scenes, number of outlets, number of assets in asset catalogs, etc.

Please ensure you write tests to accompany any code you contribute, and that SwiftLint returns no errors or warnings.


Sitrep was designed and built by Paul Hudson, and is copyright © Paul Hudson 2020. Sitrep is licensed under the Apache License v2.0 with Runtime Library Exception; for the full license please see the LICENSE file.

Sitrep is built on top of Apple’s SwiftSyntax library for parsing code, which is also available under the Apache License v2.0 with Runtime Library Exception.

Swift, the Swift logo, and Xcode are trademarks of Apple Inc., registered in the U.S. and other countries.

If you find Sitrep useful, you might find my website full of Swift tutorials equally useful: Hacking with Swift.

You can’t perform that action at this time.