Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I refactor Swift in Xcode?

Is there a way to refactor swift in Xcode 7.1?

When I try to rename a variable (e.g. highlight, right-click, refactor > rename), Xcode pops up an error dialog saying:

Can't refactor Swift code. Xcode can only refactor C and Objective-C code.

Is there a workaround for this?

like image 276
Paul Van Wieren Avatar asked Nov 03 '15 10:11

Paul Van Wieren


People also ask

How do I refactor a Swift file?

Renaming Swift codeThe renaming refactoring option can be selected from the refactoring menu by right-clicking the piece of Swift code you want to rename. It will open a new edit overview which will show all the references which will be renamed across multiple files.

How do you refactor a file?

Select the file or folder to copy in the Project tool window and press F5 or select Refactor | Copy from the context menu or from the main menu. Alternatively, select the file or the folder to copy in the Project tool window and drag it to the new folder with the Ctrl key pressed.

How do I rename a Swift file in Xcode?

Highlight the code that you want to rename. right click and choose refactor -> rename .


1 Answers

AFAIK the refactoring is not working with Swift right now, however, at least in the same file(scope), you can do the following: enter image description here

like image 92
Dániel Nagy Avatar answered Nov 13 '22 07:11

Dániel Nagy