Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

I'd like to rename a class.

like image 566
Elliot Avatar asked Jun 14 '09 07:06

Elliot


People also ask

How do I refactor names in Xcode?

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.

How do I change a class name in Swift?

Right click on class name and choose Rename. Show activity on this post. After doing what @Caroline has pointed out, you should also change the name of your . swift file because it does not change using Find > Find and replace... .


2 Answers

Select the class's symbol in its header file - i.e. the bit just after @interface. Then the refactoring stuff should be enabled.

like image 153
Noah Witherspoon Avatar answered Oct 15 '22 04:10

Noah Witherspoon


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.

like image 36
Volker Voecking Avatar answered Oct 15 '22 06:10

Volker Voecking