Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > XCode - Get Line Number Count

XCode - Get Line Number Count
Thread Tools
davecom
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jun 24, 2006, 10:04 PM
 
How do I get the number of lines in an entire project?
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jun 24, 2006, 10:17 PM
 
Do a project-wide search for "\n"?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jun 24, 2006, 10:21 PM
 
Doesn't seem to work, and also there must be a better way. I think I remember Codewarrior being able to do this easily.
     
Tick
Mac Enthusiast
Join Date: Feb 2004
Status: Offline
Reply With Quote
Jun 26, 2006, 11:39 AM
 
I was pointed at this:

http://www.dwheeler.com/sloccount/
     
bewebste
Senior User
Join Date: Mar 2000
Location: Ithaca, NY
Status: Offline
Reply With Quote
Jun 26, 2006, 11:43 AM
 
I don't know about Xcode, but I use this command line combo to get the line count of a folder full of files:

Code:
cd MyProjectFolder find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" ")" -print | xargs wc -l
This will work recursively, and you can, of course, include whatever file extensions you want to count the lines of. You could probably also whip up a similar command using Spotlight via mdfind.

I agree this should really be a feature in Xcode though.
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jun 26, 2006, 02:36 PM
 
A bit simpler, and searching all files withing a directly, and counting all instances of newlines is:
Code:
grep -d recurse "\n" path-to-parent-directory | wc -l
I just made this up, and haven't tested it much, but it seems to produce output that might be accurate I got 9096 lines for one of my small shareware projects.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:45 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,