Searching in Xcode not finding results (searching my source)

人盡茶涼 提交于 2020-01-01 03:56:07

问题


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.

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?


回答1:


At the top of the Xcode search field, you probably want to select:

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.




回答2:


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:

Find > Reference > Containing

To search for a given text, you have to re-set it to:

Find > Text > Containing



回答3:


Sometimes this happens to me when the "In Selected Items" is selected in the combobox on the right side of the search string.

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.

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.




回答4:


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.

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:



来源:https://stackoverflow.com/questions/2838817/searching-in-xcode-not-finding-results-searching-my-source

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!