在 Xcode 中搜索未找到结果(搜索我的来源)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2838817/
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
Searching in Xcode not finding results (searching my source)
提问by brs
I'm pulling my hair out on this and Google results are skewed since it thinks I want to find out how to code something.
我对此感到很困惑,而 Google 的结果却有偏差,因为它认为我想找出如何编写代码的方法。
My problem is that when trying to search my code with the String Matching box it finds nothing, even if I enter something that is on the screen below.
我的问题是,当尝试使用字符串匹配框搜索我的代码时,它什么也没找到,即使我输入了下面屏幕上的内容。
Is it Spotlight that is delivering these results? I'm not excluding anything in my Spotlight index so should I just rebuild the index?
是 Spotlight 提供这些结果吗?我没有排除 Spotlight 索引中的任何内容,所以我应该重建索引吗?
回答by pkamb
At the top of the Xcode search field, you probably want to select:
在 Xcode 搜索字段的顶部,您可能想要选择:
Find > Text > Containing
rather than
而不是
Find > Text > Matching
I did not (knowingly) switch this to "Matching", but there it was set. "Containing" is a more useful search type for most searches.
我没有(有意地)将它切换到“匹配”,但它已经设置好了。对于大多数搜索,“包含”是一种更有用的搜索类型。
回答by Giorgio Barchiesi
This happens to me after doing this: from editor, select a word, then right-click on it, then choose "Find Selected Symbol in Workspace".
这样做后我会发生这种情况:从编辑器中,选择一个单词,然后右键单击它,然后选择“在工作区中查找选定的符号”。
As a consequence, the finder automatically sets itself to:
因此,finder 会自动将自己设置为:
Find > Reference > Containing
To search for a given text, you have to re-set it to:
要搜索给定的文本,您必须将其重新设置为:
Find > Text > Containing
回答by Michael Chinen
Sometimes this happens to me when the "In Selected Items"
is selected in the combobox on the right side of the search string.
当我在"In Selected Items"
搜索字符串右侧的组合框中选择时,有时会发生这种情况。
If this selected, you only get a search in whatever files are selected in your project window. Change it to "In Project"
to search all your source files.
如果选择此项,您只能在项目窗口中选择的任何文件中进行搜索。将其更改"In Project"
为搜索所有源文件。
Note that the files need to be inside of your current Xcode project (just opening them from the finder won't add them.) You may also be interested in the "In Open Files"
option, which is faster for large projects.
请注意,这些文件需要位于您当前的 Xcode 项目中(仅从查找器中打开它们不会添加它们。)您可能还对该"In Open Files"
选项感兴趣,该选项对于大型项目而言速度更快。
回答by Mattijs
Even with all filters disabled as described in previous answers, Xcode still doesn't always find all occurrences of a string in some of my projects, even though these occurrences are reached just fine when choosing Jump to Definition.
即使按照之前的答案中的描述禁用了所有过滤器,Xcode 仍然无法在我的某些项目中找到所有出现的字符串,即使在选择跳转到定义时这些出现都很好。
To do a literal full text search (note, this is much slower than the pre-indexed search), you can create a Search Scope that just searches the full project folder, by adding a Folder location in the Scope editor:
要进行文字全文搜索(注意,这比预索引搜索慢得多),您可以创建一个仅搜索完整项目文件夹的搜索范围,方法是在 Scope 编辑器中添加一个文件夹位置:
回答by turingtested
I got stuck on this one because I didn't realize that I had to hit RETURN
to see the results, haha. Usually the search results changes dynamically as you write, but Xcode 11 apparently doesn't have that feature yet.
我被这个卡住了,因为我没有意识到我必须打RETURN
才能看到结果,哈哈。通常搜索结果会在您编写时动态更改,但 Xcode 11 显然还没有该功能。