I used "renamed" function to rename a variable named "DefaultRequestURL" in Xcode 9, it alert this: alert image I have checked the file "ComposeController.swift", there is no "DefaultRequestURL"。 I have restart Xcode and do "Product -> Clean", it still failed.
why this? What should I do?
Xcode creates a new function, and highlights its name so you can rename it. If the lines of code reference parameters, Xcode includes those in the parameter list for the new function. To rename a parameter, Command-click it and choose Edit All in Scope, or Control-click it and choose Refactor > Rename.
Luckily Xcode can take care of all the above for you. The trick is to open the interface file of the class to be renamed, select the class name in the @interface declaration and then from the Xcode Edit menu select Refactor -> Rename… Xcode then shows a dialog box prompting you for the new name of the class.
Try again in few minutes. Maybe background indexing still running. Also, you must build your project in order to be able to use refactor->rename. Actually, it must be a bug in Xcode 9. Try 9.1 beta, refactor is not ideal, but works better there. this maybe helpful: https://forums.developer.apple.com/thread/80331
UPDATE:
~/Library/Developer/Xcode/DerivedData
and remove folder contents including "ModuleCache".Update 2:
For Xcode 10, it's enough just to restart it.
Update 3:
Still works for Xcode 12. Sometimes just restart helps, sometimes module cache needs to be removed. Sometimes even build->clean helps.
Thanks for Vlad E. Borovtsov, It's help me to resolve problem and I fonud there is a way not close xcode. This is my way to fix it:
Go to ~/Library/Developer/Xcode/
, remove DerivedData
folder
command+r to run ,or command+b to build
Try rename , it work for me .
xocde reindex and rename can work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With