How to find how many lines of Code are in your Swift project

Jay Wilson
2 min readApr 10, 2022

Photo by Markus Spiske on 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.

If you want to help me out, then consider subscribing to Medium using this link and part of your medium subscription will go towards me.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Jay Wilson
Jay Wilson

Written by Jay Wilson

I like to solve problems using Swift, make YouTube videos, and take photos. I also really enjoy a good cup of coffee.

No responses yet

Write a response