How to find duplicate lines of code in Xcode When I am making applications in Xcode, I sometimes find that I write duplicate code. 

Is there a way in Xcode to find duplicate code in all files? I would like to know this because I would put the code into a function instead.
Not in Xcode itself, but there are third party solutions. They both can analyse Swift code.


PMD, it includes CPD, the copy-paste-detector.
jscpd, a copy/paste detector for programming source code