Rename a class in Xcode: Refactor… is grayed out (disabled). Why?

后端 未结 10 1445
清歌不尽
清歌不尽 2020-12-13 23:00

Why is Refactor... grayed out (disabled) in Xcode?

I\'d like to rename a class.

相关标签:
10条回答
  • 2020-12-13 23:34

    Also, it could happen that you renamed the filename for the class, either outside xcode or by ctrl-clicking the filename and then renaming it. xcode refuses to refactor if filename does not match with the class name.

    0 讨论(0)
  • 2020-12-13 23:36

    If you are using Objective-C++ (i.e. mix Objective-C with C++ code) then refactoring is disabled in xcode since it does not support refactoring of C++ code.

    0 讨论(0)
  • 2020-12-13 23:41

    For me I realized Refactor was disabled because the Xcode project I had opened was referencing a Base SDK that was missing. Edit Project Settings and in the Build tab set the Base SDK to one that you have (like for me this was iOS 4.2). This enabled Refactor for me.

    0 讨论(0)
  • 2020-12-13 23:42

    Go to your class' header file and find the line that looks similar to this:

    @interface YourClassName
    

    Right click on the class symbol (e.g. YourClassName) and you should be able to select Refactor -> Rename...

    I just tried this and it works in Xcode 5.

    0 讨论(0)
提交回复
热议问题