Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode - search scope to exclude files or path

Tags:

xcode

ios

If your project is big and has many localizations, sometimes you find view controllers by searching for text displayed on that view controller's view. But in doing so you get a lot of search results you don't need that can make finding the file you're searching for cumbersome:

enter image description here

If you're like me and do this a hundred times a day, you want to have a way to omit Localizable files from your searches, for example. How?

like image 967
Alex the Ukrainian Avatar asked Sep 26 '14 18:09

Alex the Ukrainian


Video Answer


2 Answers

  1. In the Find Navigator tab, click the current search scope directly underneath the search bar:

where to click under search bar

  1. Click "New Scope..." and give it a name. I picked 'Workspace W/O Localizable":

new search scope configuration

  1. Add a Path condition that 'matches regex'. You can use a negative regex to exclude paths with "Localizable" in it. The regex to use is this: ^((?!Localizable).)*$

That's it! Just click the new search scope under "SEARCH SCOPES" and it will be the new default.

like image 126
Alex the Ukrainian Avatar answered Nov 09 '22 08:11

Alex the Ukrainian


Quick tip which is a solution for some. You can easily change this by clicking on a result and hitting "delete." This will remove the result or group of results from the list. It will not affect your code ;)

like image 26
Brooks Hanes Avatar answered Nov 09 '22 09:11

Brooks Hanes