How to find how many lines of code is in your Swift Project

How to find how many lines of code is in your Swift Project
Photo by Joshua Aragon / Unsplash

I was streaming my work on coffee_ the other day, and @MikaelaCaron sent me a snippet on how to find how many lines of code the app was.

If you're just here for the code snippet, then here it is.


find . -path ./Pods -prune -o -name '*.swift' -print0 ! -name '/Pods' | xargs -0 wc -

Here is how you can use the snippet:

  1. Open your terminal of choice. I'm currently using Warp, but you could use Apple's built in Terminal or iTerm 2.
  2. Change directory to the working directory of your project that has the .xcodeproj file
    Image
  3. Run the snippet find . -path ./Pods -prune -o -name '*.swift' -print0 ! -name '/Pods' | xargs -0 wc - and you'll see each .swift file listed with how many lines of code each file has and the total.

Image

It's a nifty script, so I thought I'd share it. coffee_ has about 1815 lines of code so far.