Xcode 9 (beta) refactoring: Rename broken

邮差的信 提交于 2019-12-24 07:01:14

问题


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:

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

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


回答1:


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



回答2:


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!




回答3:


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.



来源:https://stackoverflow.com/questions/44833848/xcode-9-beta-refactoring-rename-broken

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!