Is there a way to determine how many lines of code an Xcode project contains? I promise not to use such information for managerial measurement or employee benchmarking purposes. ;)
Is there a way to determine how many lines of code an Xcode project contains? I promise not to use such information for managerial measurement or employee benchmarking purposes. ;)
Check out CLOC.
cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
In terminal, change into the project directory and run:
find . -type f -print0 | xargs -0 cat | wc -l
If you want only certain file types, try something like
find . -type f -name \*.[ch]* -print0 | xargs -0 cat | wc -l
Check out Xcode Statistician, it does exactly what you want. It also provides other interesting statistics so is worth a run for fun now and then.
Note that it will not look inside real folders, though it will look in groups. Odds are you aren't using real folders so it'll work great. If you are using folders then you just have to do the count in each folder and add them together.
Note: As of June, 2012, it seems this does not work properly with the latest versions of Xcode.
Steps to implement CLOC library in Mac as below:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Enter system password if asked.
You will see the terminal screen as below.
System will popup so many permissions, allow all the permissions
If everything goes fine, you will see terminal screen as below,
brew install cloc
cloc . --exclude-dir=Pods (to exclude pod files)
cloc . (including pod files)
If everything goes fine, it will display the number of lines of code as below,
A quick & easy way:
Use a regex search (Find Navigator, choose Find > Regular Expression).
.\n
Works conveniently with Xcode search scopes and you can easily customize it to whatever type of line you'd like to count ;).