第一种方式:使用mac终端
如果要统计ios开发代码,包括头文件的,终端命令进入项目目录下,命令如下
- find
. -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs wc -l
列出每个文件的行数
- find
. -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs grep -v "^$"|wc -l
列出代码行数总和
- grep -v "^$"是去掉空行
- 注释也统计在代码量之内,毕竟也一个字一个字码出来的
第二种方式:使用CLOC工具,有一定知名度的代码统计工具
1,快捷命令----安装brew
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
2,安装cloc工具
sudo brew install cloc
3,终端--进入项目 执行 $ cloc ./
ok,成功了
两种方式比较:前者是统计所有的代码行量,包含你的注释,后者只是统计有效代码量,希望有所帮助