Alex the Ukrainian
Alex the Ukrainian

Reputation: 4568

Xcode - search scope to exclude files or path

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?

Upvotes: 12

Views: 4865

Answers (3)

justdan0227
justdan0227

Reputation: 1362

Quick tip for xCode 9.4. Create a search scope of this to search just the swift files in your project. enter image description here

Upvotes: 1

Brooks Hanes
Brooks Hanes

Reputation: 425

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 ;)

Upvotes: 4

Alex the Ukrainian
Alex the Ukrainian

Reputation: 4568

  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.

Upvotes: 31

Related Questions