Count Lines of Code for Mac/ iOS projects

Arshad
Nov 19, 2020

--

There will always be a time when some one comes to you and ask for lines of code in your project or how many lines of code you write a day ?

There can also be a situation where they ask for an application idea in an interview and ask how many lines of code you think will be written. Now there is no perfect answer for this but if you have not run the tools in your projects that you have worked in past answering this can be tricky.

Below are some of the terminology been used for Lines of codes.

Count lines of code (CLOC)

Lines of code (LOC)

Logical lines of code (LLOC)

There are different projects available in gitHub for calculating it.

Appmakers have published the below command.

For calculating the lines of code in Mac we can follow below steps

  • Open terminal on your mac
  • Type cd in terminal to navigate to your Xcode project directory
  • Inside your project in terminal type this to find only .swift files:
 find . -name "*.swift" -print0 | xargs -0 wc -l
  • You will get the results with the number of lines in terminal and with the total number of lines related to listed files at the bottom.

To exclude the Pods file run below command

find . -path ./Pods -prune -o -name "*.swift" -print0 ! -name “/Pods” | xargs -0 wc -l

References

https://github.com/

https://appmakers.dev/how-to-count-lines-in-xcode-project

--

--