Xcode can only refactor C and Objective-C code. How to rename swift class name in Xcode 6?
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?
Finally Xcode 9 is supporting Refactoring for Swift. It took Apple 3 years to add this basic feature. Refactoring
- iOS: autolayout for multiple button
- WatchKit error - unable to find interface controller class '' to instantiate
- How we can add additional UILabels to UINavigation?
- Caught NSInternalInconsistencyException request for rect at invalid indexPath
- Upload Library or captured images on iOS with Flex Mobile 4.6
- Change Single Language of Xcode Project
6 Solutions Collect From Internet About “Xcode can only refactor C and Objective-C code. How to rename swift class name in Xcode 6?”
You can change name of a class in File Inspector at the right side of Xcode6.
- open your class
- go to File Inspector > Identify and type section
- rename existing class in “name” field.
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.
I use this way:
- You can positioning the cursor on the variable that you want rename
- Select Editor – Edit all in Scope (^⌘E)
- Rename the variable and automatically all variable occurrences is edit
From this tutorial.
Split up your iOS8 Swift Code
First things first, let’s rename our View Controller to be something more meaningful. Open up your ViewController.swift file and replace all references to ‘ViewController’ with our new name, ‘SearchResultsViewController’. Rename the file as well to SearchResultsViewController.swift.
If you try to run the app from here you’ll get a crash. This is because our storyboard file hasn’t been updated to know about the new class! So open up the Main.storyboard, select your ‘View Controller’ object in the scene (the left-hand side nav), and then select the Identity Inspector (right-hand side, third button.)
From here let’s change the class from ‘ViewController’ to ‘SearchResultsViewController’. Now we should be back on track. Check that the project still works, and let’s proceed.
Xcode 9 now supports renaming in Swift. This was announced in WWDC 2017.
- In OS X 10.10 (Yosemite Beta), How do I Test Using iOS 6.1 Simulator?
- Unintended table reload/refresh with some delay
- Change detail view from MasterDetail iPad app using storyboard
- Change Google Maps' Selected Marker or change marker's color?
- Code signing fails for Cordova app (using XCode 5.1.1 and Cordova 3.4.1-0.1.0)
- how can I remove the top border on UIToolBar
- Swift – Generic methods
- ObjC to Swift conversion of NSDictionary to NSObject : AnyObject
- Can I release an app without the device?
- How to block days in UIDatePicker for iOS
- UISearchDisplayController's full-screen background intercepts touch events in iOS 7
- AVPlayer wont play video from url in iOS9
- UITextView's inputView on iOS 7
- NSDateFormatter Trouble?
- Convert between UIImage and Base64 string