統(tǒng)計xcode代碼行數(shù)

如果要統(tǒng)計ios開發(fā)代碼,包括頭文件的,終端命令進(jìn)入項目目錄下,命令如下

find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs wc -l  

log 如下
列出每個文件的行數(shù)

      17 ./mytest/AppDelegate.h
      45 ./mytest/AppDelegate.m
      16 ./mytest/main.m
      29 ./mytest/MyObject.h
      30 ./mytest/MyObject.m
       4 ./mytest/mytest-Bridging-Header.h
      14 ./mytest/ViewController.h
     852 ./mytest/ViewController.m
      39 ./mytestTests/mytestTests.m
      40 ./mytestUITests/mytestUITests.m
    1086 total

你可以將你需要的文件行數(shù)直接相加,或者你可以直接使用下面的命令
列出代碼行數(shù)總和 :

find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs grep -v "^$"|wc -l  

log 如下

950

當(dāng)你的工程是swift 和OC 混編的情況下,你需要添加 -name "*.swift" 來統(tǒng)計swift 里面的行數(shù)

find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" -or  -name "*.swift" |xargs wc -l 

log 如下

bogon:mytest chengguangfa$ find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" -or  -name "*.swift" |xargs wc -l 
      17 ./mytest/AppDelegate.h
      45 ./mytest/AppDelegate.m
      16 ./mytest/main.m
      29 ./mytest/MyObject.h
      30 ./mytest/MyObject.m
       4 ./mytest/mytest-Bridging-Header.h
      21 ./mytest/testOK.swift
      14 ./mytest/ViewController.h
     852 ./mytest/ViewController.m
      39 ./mytestTests/mytestTests.m
      40 ./mytestUITests/mytestUITests.m
    1107 total

grep -v "^$"是去掉空行
注釋也統(tǒng)計在代碼量之內(nèi)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容