Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Know how many lines of code you have in an Xcode project?

I've got quite a big project and eventually I finished it. I'm just curious to know how many lines of code there are altogether in my project. I'm using Xcode 3. So can you actually find out how many lines of code have been compiled?

like image 378
LA12 Avatar asked Aug 28 '11 22:08

LA12


People also ask

How do you count how many lines of code a project has?

To use cloc simply type cloc followed by the file or directory which you wish to examine. Now lets run cloc on it. As you can see it counted the number of files, blank lines, comments and lines of code. Another cool feature of cloc is that can even be used on compressed files.


1 Answers

Open up Terminal.app, go into your project's root directory, and run this command:

For Swift only:

find . \( -iname \*.swift \) -exec wc -l '{}' \+ 

For Obj-C only:

find . \( -iname \*.m -o -iname \*.mm -o -iname \*.h \) -exec wc -l '{}' \+ 

For Obj-C + Swift:

find . \( -iname \*.m -o -iname \*.mm -o -iname \*.h -o -iname \*.swift \) -exec wc -l '{}' \+ 

For Obj-C + Swift + C + C++:

find . \( -iname \*.m -o -iname \*.mm -o -iname \*.c -o -iname \*.cc -o -iname \*.h -o -iname \*.hh -o -iname \*.hpp -o -iname \*.cpp -o -iname \*.swift \) -exec wc -l '{}' \+ 

Terminal quick tips:
ls: list directory contents
cd: change directory
Press tab to autocomplete
Remember to put "\" backslash before spaces
I suggest going one folder down from the main project so you get rid of code count from the frameworks

like image 78
Esqarrouth Avatar answered Sep 20 '22 14:09

Esqarrouth