How to find how many lines of Code are in your Swift project
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:
- Open your terminal of choice. I’m currently using Warp, but you could use Apple’s built in Terminal or iTerm 2.
- Change directory to the working directory of your project that has the
.xcodeproj
file

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.

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.