Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Count lines of code in SWIFT Xcode project
1. Open Terminal
2. cd to your Xcode project
3. Execute the following when inside your target project:
find . -name "*.swift" -print0 | xargs -0 wc -l
@jstheoriginal

This comment has been minimized.

Copy link

jstheoriginal commented Dec 10, 2015

swiftified! thanks.

@acidlynx

This comment has been minimized.

Copy link

acidlynx commented Mar 2, 2016

# brew install cloc
# cd path/to/project/
# cloc .
@nunogoncalves

This comment has been minimized.

Copy link

nunogoncalves commented May 19, 2016

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

(excluiding ./Pods from find)

@Exey

This comment has been minimized.

Copy link

Exey commented Dec 23, 2016

Mixed ObjC + Swift project:
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

@Rahulgupta-cdnsol

This comment has been minimized.

Copy link

Rahulgupta-cdnsol commented Jan 4, 2018

How to exclude Comments and empty lines while counting the total number of lines, please suggest.

@cornr

This comment has been minimized.

Copy link

cornr commented Jan 3, 2019

For Jenkins Integration I suggest using cloc and SLOCCount Plugin.

Our cloc command looks something like this
cloc . --exclude-dir=Carthage,Frameworks,generated,.idea,output,derivedData,Fastlane --not-match-d=.*\.framework --by-file --xml --out=output/cloc.xml

@jakebromberg

This comment has been minimized.

Copy link

jakebromberg commented Mar 13, 2019

How would you exclude test files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.