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

前端 未结 15 1607
闹比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:39

    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

提交回复
热议问题