Where do I find the line number in the Xcode editor?
Asked Answered
N

6

554

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?

Nutter answered 5/5, 2011 at 17:23 Comment(1)
Please file bugs at bugreport.apple.com and reference radar://9245044 (for showing cursor line & column) or radar://13255659 (to show line numbers by default).Cockeye
L
991

For Xcode 4 and higher, open the preferences (command+,) and check "Show: Line numbers" in the "Text Editing" section.

Xcode 9 enter image description here

Xcode 8 and below Xcode Text Editing Preferences screen capture with Text Editing and Line Numbers highlighted

Lenten answered 5/5, 2011 at 17:26 Comment(1)
A image is worth a 1000 words! (it´s still the same for xcode 6.. )Cosetta
H
42

In Preferences->Text Editing-> Show: Line numbers you can enable the line numbers on the left hand side of the file.

Holeandcorner answered 5/5, 2011 at 17:25 Comment(2)
Thanks, 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.Nutter
@William Jockusch I don't think they kept it in XCode4, I've been looking nor for quite a while but to no avail.Lenten
G
19

Sure, Xcode->Preferences and turn on Show line numbers.

Gemmiparous answered 5/5, 2011 at 17:26 Comment(1)
Preferences->Text Editing-> Show: Line numbersEstas
O
6
  1. Go to Xcode preferences by clicking on "Xcode" in the left hand side upper corner.

  2. Select "Text Editing".

  3. Select "Show: Line numbers" and click on check box for enable it.

  4. Close it.

Then you will see the line number in Xcode.

Overskirt answered 18/9, 2014 at 11:45 Comment(0)
E
1

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.

Extrajudicial answered 30/1, 2018 at 10:10 Comment(0)
C
1

To save $4.99 for a one time use and no dealing with HomeBrew and no counting empty lines.

  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

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
Cerium answered 17/4, 2019 at 3:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.