iOS Notes 34 : How to check line of codes ? [ LOC ]
Published in
2 min readJul 20, 2017
Hey,
I’m sure that everyone loves to check how many lines of codes ( LOC ) did they write :) LOC is also important for calculating project management.
Let’s check how can we check our LOC. We have two methods :
First Method :
- Open Terminal
- cd to your Xcode project ( ex :
cd path/to/project/
) - Execute the following code segment when inside your target project:
Swift Files :
find . -name "*.swift" -print0 | xargs -0 wc -l
Swift Files Excluding ./Pods :
find . -path ./Pods -prune -o -name "*.swift" -print0 ! -name "/Pods" | xargs -0 wc -l
Swift + Objective C Files :
find . -type d \( -path ./Pods -o -path ./Vendor \) -prune -o \( -iname \*.m -o -iname \*.mm -o -iname \*.h -o -iname \*.swift \) -print0 | xargs -0 wc -l
Method 2 :
This method uses cloc library via homebrew: Cloc Library
First we need to install cloc with homebrew.
brew install cloc
Now let’s find out our LOC
# cd path/to/project/
# cloc .
Cloc gives much more details but it’s all up to you :)
If you have any question, ask me :)