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?
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.
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.
Highlight the code that you want to rename. right click and choose refactor -> rename .
AFAIK the refactoring is not working with Swift right now, however, at least in the same file(scope), you can do the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With