计算 Xcode 项目中的总行数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28764408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:44:19  来源:igfitidea点击:

Count total number of lines in an Xcode project

xcoderowcount

提问by user3892683

What is the way to count total number of lines in an Xcode Project? I can see number of lines in an individual file but I need a sum up of all the lines in a project.

计算 Xcode 项目中总行数的方法是什么?我可以看到单个文件中的行数,但我需要一个项目中所有行的总和。

采纳答案by Fogmeister

There is an app on the App Store called Xcode Statistics. (Or something like that). It does what you want.

App Store 上有一个名为Xcode Statistics的应用程序。(或类似的东西)。它做你想做的。

A word of warning though. The number of lines in a project has little to no relation to the quality or complexity of that project.

警告的话。项目中的行数与该项目的质量或复杂性几乎没有关系。

回答by Tim

A lightweight solution if you're using Homebrew (and a fan of the terminal) is the command-line program 'Cloc' (count lines of code). It breaks down the output for languages used in your project and gives you other useful information.

如果您使用的是 Homebrew(以及终端爱好者),一个轻量级的解决方案是命令行程序“Cloc”(计算代码行数)。它分解了项目中使用的语言的输出,并为您提供了其他有用的信息。

Cloc

时钟

$ brew install cloc 
$ cd path/to/project/ 
$ cloc .

回答by ScottyBlades

If you don't want to pay $4.99 for a one time use, and you don't want to bother with HomeBrew. While it does count the empty lines between your code, you can do this:

如果您不想为一次使用支付 4.99 美元,并且不想为 HomeBrew 烦恼。虽然它确实计算了代码之间的空行,但您可以这样做:

  1. Open Terminal
  2. cd to your Xcode project
  3. Execute the following when inside your target project:
  1. 打开终端
  2. cd 到您的 Xcode 项目
  3. 在目标项目中执行以下操作:

find . -name "*.swift" -print0 | xargs -0 wc -l

find . -name "*.swift" -print0 | xargs -0 wc -l

If you want to exclude pods:

如果要排除 pod:

find . -path ./Pods -prune -o -name "*.swift" -print0 ! -name "/Pods" | xargs -0 wc -l

If your project has objective c and swift:

如果您的项目有目标 c 和 swift:

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

回答by Chanchal Raj

Check out: CLOC

退房:CLOC

ClOC counts blank lines, comment lines, and physical lines of source code.

ClOC 计算源代码的空白行、注释行和物理行。

To use CLOC (Count Lines Of Code) for count number of lines in a project. Download the the CLOC .pl file and write following line in terminal:

使用 CLOC(计算代码行数)来计算项目中的行数。下载 CLOC .pl 文件并在终端中写入以下行:

perl ./DirectoryWhereClockFileIS/cloc-1.56.pl ./YourDirectoryWhereYourSourcesAre

It will show you results like:

它会显示如下结果:

enter image description here

在此处输入图片说明