iOS Notes 34

iOS Notes 34 : How to check line of codes ? [ LOC ]

Kuray Ogun
FreakyCoder Software Blog
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 :

  1. Open Terminal
  2. cd to your Xcode project ( ex : cd path/to/project/ )
  3. Execute the following code segment when inside your target project:

Swift Files :

find . -name "*.swift" -print0 | xargs -0 wc -l
total line of code of all Swift files

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
total line of codes Swift + ObjC files

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 Line of codes

Cloc gives much more details but it’s all up to you :)

If you have any question, ask me :)

--

--