1

None of the refactor tools are working for me in XCode 9 beta. This is true even for new projects created with the beta (as with the test project, screenshot below). What gives?

I've found several demonstrations on YouTube showing the Xcode 9 rename refactor, but when I control-click on, say, a function name, the four refactoring options are all grayed out, including "Rename…".

Today I installed beta 2 in hopes that that would fix the issue, but still:

enter image description here

Is there some setting or something I need to change to enable refactoring?

If not, what's the best way to troubleshoot this?

clozach
  • 5,118
  • 5
  • 41
  • 54

3 Answers3

0

You should check the following options:

  1. Use Find Navigator to get all references of this function and refactor it. (It would be a bit hard to do so if the project is of a big size)
  2. Check the compatibility of the Xcode project, Keep backup and try to open it in older Xcode version, then refactor it (although it might not compile there but will allow you to refactor).
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
  • 1
    Your #1 doesn't answer either question. As for #2, I've edited my question to clarify that the problem I'm experiencing happens even with brand new projects created with the latest Xcode 9 beta, so it's not possible for this to be a project compatibility issue. Clearly, based on the YouTube links I listed, others are able to use the new editor's refactoring, and my goal is to experiment with the new features. So what I'm looking for here is not workarounds, but actual fixes or, at the very least, knowledgeable suggestions for troubleshooting my beta installation. – clozach Jun 30 '17 at 21:29
0

Was feeling too fed up to troubleshoot the issue carefully, but this managed to fix it, even if I can't say for sure whether the problem was a borked preference file or a corrupt Xcode bundle.

  1. Moved all xcode-related preference files files out of ~/Library/Preferences into a temp dir

    • com.apple.dt.Instruments.plist
    • com.apple.dt.Xcode.Playground.plist
    • com.apple.dt.Xcode.plist
    • com.apple.dt.xcodebuild.plist
    • com.apple.preferences.extensions.XcodeSourceEditor.plist
  2. Deleted /Applications/Xcode-beta.app and reinstalled from a fresh download

Both new and old projects seem to have refactoring working again instead of all grayed out. Even after dragging the moved preferences back in place, all's well!

clozach
  • 5,118
  • 5
  • 41
  • 54
0

For the first time I opened my project, I clicked on a variable name and hit refactor >> rename. But then the spinner on it took for ever. I deleted my derived data, but that didn't work either. What did the trick was building the project. Not sure if it's the same for you. Also the indexing needs to become completed, otherwise it would take forever.

mfaani
  • 33,269
  • 19
  • 164
  • 293