Failed to rename in Xcode 9

I used the "renamed" function to rename a variable named "DefaultRequestURL" in Xcode 9, it warns about this: alert image I checked the file "ComposeController.swift", there is no "DefaultRequestURL". I restarted Xcode and doing "Product -> Clear", it still failed.

why is this? What should I do?

+29
rename xcode9
source share
3 answers

Try again in a few minutes. Maybe background indexing is still working. In addition, you must build your project in order to be able to use refactor-> rename. Actually, this should be a mistake in Xcode 9. Try 9.1 beta, refactoring is not perfect, but it works better there. this might be useful: https://forums.developer.apple.com/thread/80331

UPDATE:

  1. Close Xcode
  2. Go to ~/Library/Developer/Xcode/DerivedData and delete the contents of the folder, including "ModuleCache".
  3. Open your project and build
  4. Try renaming the functionality now. It should work!

Update 2:

For Xcode 10, just restarting it is enough.

+54
source share

Thanks for Vlad E. Borovtsov, Help me solve the problem, and I realized that there is a way not to close xcode. This is my way to fix this:

  • Go to ~/Library/Developer/Xcode/ , delete the DerivedData folder

  • + r command to run or + b command to build

  • Try renaming, it works for me.

xocde reindex and rename may work

+9
source share

There is no need to delete the DerivedData folder and rebuild.

  1. close Xcode
  2. delete the DerivedData / ModuleCache.noindex folder
  3. open xcode
  4. rename / refactor

Powered by 10.2.1

0
source share

All Articles