Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force indexing manually in Xcode?

Tags:

indexing

xcode

Sometimes I switch branches and a lot of the code is different, yet Xcode does not always trigger the indexing automatically and the search results for symbols are all wrong. So I would like to know how to force a reindex of all project files in Xcode. No hacks such as deleting DerivedData/restarting Xcode.

like image 245
Fuad Avatar asked May 01 '20 20:05

Fuad


1 Answers

So it seems this issue calls for "Best hack wins".

In the question @Fuad mentioned two hacks: DerivedData & restarting Xcode ...Personally, I think these ones are a little too much effort. That's probably just because I'm lazy and impatient.

Note: Please take 20 seconds to just read a valid point @VladRusu made in the comments of this answer. Other than that - Go ahead, follow the steps and enjoy a nice little hack!


Here's what I do:

  • Open your terminal and simply run pod install
  • When doing pod install, make sure you actually have a Podfile
  • If you don't have a Podfile, simply run pod init, then repeat the above everytime you need Xcode to re-index.

...And voila!! your project should now snap out of its lazy *ss state and start indexing.


Here's a couple of things that's always good to know:

  1. You need to be in the directory where your Podfile is in. If not, your Terminal will throw you some nasty comments!
  2. You don't need to have any pods installed for this. Pod install will still do its magic.
  3. If you don't have a Podfile, simply run pod init, then run pod install everytime you need Xcode to re-index.

One last thing.... We all know pod install isn't some magical command. It cleary does something in the background that triggers Xcode to start re-indexing. If you want to be the Hero of the day, go investigate what exactly they're doing and if you have the answer, come share it and you'll become the ultimate Xcode hero!

like image 57
PhillipJacobs Avatar answered Sep 28 '22 03:09

PhillipJacobs