我在哪里可以找到 Xcode 编辑器中的行号?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5901758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:56:04  来源:igfitidea点击:

Where do I find the line number in the Xcode editor?

xcode

提问by William Jockusch

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?

在 Xcode 3 中,显示了当前光标位置的行号。我在 Xcode 4 中没有看到这个。有没有设置可以打开它?或者给我一个按键?

回答by Nick Weaver

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

对于 Xcode 4 及更高版本,打开首选项 ( command+ ,) 并选中“文本编辑”部分中的“显示:行号”。

Xcode 9enter image description here

Xcode 9在此处输入图片说明

XCode 8 and belowXcode Text Editing Preferences screen capture with Text Editing and Line Numbers highlighted

XCode 8 及以下Xcode 文本编辑首选项屏幕截图,其中突出显示了文本编辑和行号

回答by wasabi

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

在首选项-> 文本编辑-> 显示:行号中,您可以启用文件左侧的行号。

回答by Roger

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

当然,XCode->首选项并打开显示行号。

回答by C_compnay

1) go to xcode preference by clicking on xcode on left hand side uper corner.

1)通过单击左侧上角的 xcode 转到 xcode 首选项。

2) then select Text Editing

2)然后选择文本编辑

3) then select Show: Line numbers and click on check box for enable it.

3)然后选择显示:行号并单击复选框以启用它。

4) close it.

4)关闭它。

5) you will see the line number in xcode.

5) 您将在 xcode 中看到行号。

回答by Pierz

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.

如果您不想一直显示行号,另一种查找代码行号的方法是单击最左边的边距并创建一个断点(出现一个蓝色小箭头),然后转到断点navigator ( ?7) 它将列出断点及其行号。您可以通过右键单击断点来删除断点。

回答by ScottyBlades

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

一次性使用可节省 4.99 美元,无需处理 HomeBrew,也无需计算空行。

  1. Open Terminal
  2. cd to your Xcode project
  3. Execute the following when inside your target project:
  1. 打开终端
  2. cd 到您的 Xcode 项目
  3. 在目标项目中执行以下操作:

find . -name "*.swift" -print0 | xargs -0 wc -l

find . -name "*.swift" -print0 | xargs -0 wc -l

If you want to exclude pods:

如果要排除 pod:

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

If your project has objective c and swift:

如果您的项目有目标 c 和 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