I have created a new Single View Application Project in Xcode 6 beta version. I want to rename swift class from ViewController.swift
to some other name. But when I select Refactor -> Rename, it gives error Xcode can only refactor C and Objective-C code
.
Any idea how to rename swift class in Xcode 6?
UPDATE:
Finally Xcode 9 is supporting Refactoring for Swift. It took Apple 3 years to add this basic feature. Refactoring
Luckily Xcode can take care of all the above for you. The trick is to open the interface file of the class to be renamed, select the class name in the @interface declaration and then from the Xcode Edit menu select Refactor -> Rename… Xcode then shows a dialog box prompting you for the new name of the class.
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.
The Swift library cannot be directly called from Objective-C, since it is missing the required annotations in the code, and in many cases, modules do not inherit from NSObject, rather they use the native Swift data types.
You can work with types declared in Swift from within the Objective-C code in your project by importing an Xcode-generated header file. This file is an Objective-C header that declares the Swift interfaces in your target, and you can think of it as an umbrella header for your Swift code.
You can change name of a class in File Inspector at the right side of Xcode6.
That's all! Previously I manually rename the class name in the class file.
I've been using Find>Find & Replace in Project, it's not perfect but it works.
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