How to find out how many lines of code there are in an Xcode project?

前端 未结 15 1540
闹比i
闹比i 2020-11-30 16:32

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 purp

相关标签:
15条回答
  • 2020-11-30 16:46

    Steps to implement CLOC library in Mac as below:

    1. Open terminal

    2. Install Homebrew using command as below,

      ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

      Copy & paste this command, including double quotes in terminal

      Enter system password & click enter.

    3. You will see the terminal screen as below,

    4. System will popup so many permissions, please allow all the permissions

    5. If everything goes fine, you will see terminal screen as below,

    6. Redirect to project folder using cd drag & drop project folder path to terminal

    7. Now its time to install CLOC using below command

      cloc . --exclude-dir=Pods used to exclude pod files

      cloc . including pod files

    8. If everything goes fine, it will display the number of lines of code as below,

      Hope it will help someone.

    0 讨论(0)
  • 2020-11-30 16:53

    Sorry for repeating. That's the easiest way IMHO:

    1. In terminal type

    find /users/<#username#>/documents/folderWithProject/ -type f -exec cp {} /users/<#username#>/documents/folderWithProject/newFolder/ \;

    This will copy all files from project folder to newFolder.

    1. Download Xcode Statistician and use it with newFolder
    0 讨论(0)
  • 2020-11-30 16:55

    I see this floating around and use it myself:

    find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.swift" ")" -print0 | xargs -0 wc -l
    
    0 讨论(0)
  • 2020-11-30 16:56

    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
    
    0 讨论(0)
  • 2020-11-30 16:56

    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.

    0 讨论(0)
  • 2020-11-30 16:56

    Nozzi's version doesn't work for me, but this one:

    find . -type f -print0 | xargs -0 cat | wc -l
    
    0 讨论(0)
提交回复
热议问题