Number of classes in project/workspace

2.1k views Asked by At

Is there any way to get the number of classes in a project or the complete workspace in Xcode?

2

There are 2 answers

0
TobiasMende On BEST ANSWER

You could use cloc which can also be installed via Homebrew: brew install cloc.

Cloc is an open source command line tool for counting lines of code, but it also provides the count of files grouped by file type. The simplest form is cloc <path-to-your-project-dir> but the output can be configured by parameters.

A more complex solution (IMHO too complex) is, using Sonarqube with an Objective C plugin. Sonarqube has a nice interface and many functions, but just for counting classes, it's way to much.

0
devios1 On

A simple way to get a rough idea for a project is by checking the Compile Sources section of the project's Build Phases. The compile sources will list all source files (.m, .swift) and doesn't include any headers.

Assuming roughly one class per source file, this will give you a ballpark idea of how many classes there are in your project at a glance. Note that this doesn't include any embedded projects or frameworks.

enter image description here