In Xcode 3, the line number of the current cursor location was displayed. I don't see this in Xcode 4. Is there a setting that will turn it on? Or a keypress that will give it to me?
-
Please file bugs at http://bugreport.apple.com and reference radar://9245044 (for showing cursor line & column) or radar://13255659 (to show line numbers by default). – Quinn Taylor Oct 19 '15 at 22:12
6 Answers
For Xcode 4 and higher, open the preferences (command+,) and check "Show: Line numbers" in the "Text Editing" section.
Xcode 8 and below

- 9,289
- 12
- 69
- 108

- 47,228
- 12
- 98
- 108
In Preferences->Text Editing-> Show: Line numbers you can enable the line numbers on the left hand side of the file.

- 1,110
- 10
- 23
-
5Thanks, I will use that at least some of the time. But what I really want is to just display the number of the line I am on. – William Jockusch May 05 '11 at 17:27
-
@William Jockusch I don't think they kept it in XCode4, I've been looking nor for quite a while but to no avail. – Nick Weaver May 05 '11 at 17:49
If you don't want line numbers shown all the time another way to find the line number of a piece of code is to just click in the left-most margin and create a breakpoint (a small blue arrow appears) then go to the breakpoint navigator (⌘7) where it will list the breakpoint with its line number. You can delete the breakpoint by right clicking on it.

- 7,064
- 52
- 59
To save $4.99 for a one time use and no dealing with HomeBrew and no counting empty lines.
- Open Terminal
- cd to your Xcode project
- Execute the following when inside your target project:
find . -name "*.swift" -print0 | xargs -0 wc -l
If you want to exclude pods:
find . -path ./Pods -prune -o -name "*.swift" -print0 ! -name "/Pods" | xargs -0 wc -l
If your project has objective c and swift:
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

- 12,189
- 5
- 77
- 85