Open your terminal, navigate to the project’s root directory and then run this command:
find . "(" -name "*.m" -or -name "*.mm" -or -name "*.h" -or -name "*.cpp" -or -name "*.c" -or -name "*.cc" -or -name "*.hh" -or -name "*.hpp" -or -name "*.swift" ")" -print0 | xargs -0 wc -l
This will calculate the lines of code of all Swift, Objective-C, C, and C++ files and show the count for each file separately and also the total in the end.
For example, here I ran this command in the sample-food-truck project:
You can see the total is 8211 and all the files have less than 200 lines of code except SubscriptionStoreView.swift
(Maybe consider refactoring?).
If you are using CocoaPods in your project and want to exclude pod files, run this command in the project’s root directory:
find . -path ./Pods -prune -o "(" -name "*.m" -or -name "*.mm" -or -name "*.h" -or -name "*.cpp" -or -name "*.c" -or -name "*.cc" -or -name "*.hh" -or -name "*.hpp" -or -name "*.swift" ")" -print0 ! -name "/Pods" | xargs -0 wc -l